Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions author- RIYA SINGHAL(1).c
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@

#include <stdio.h>
int main()
{
int x;
printf("enter the no. to be divided");
scanf("%d",x);
for(int i=0;i<=5;i+=1)
int x,i;
printf("enter the no. to be divided: ");
scanf("%d",&x);
for(i=1;i<=5;i+=1)
{
int y=x/i;
printf("\n the quotient after dividing the given no. by %d is %d",i,y)
float y=(float)x/i;
printf("\n the quotient after dividing the given no. by %d is %.2f",i,y);
}
return 0;
}
}
7 changes: 3 additions & 4 deletions author- RIYA SINGHAL(3).c
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@

#include <stdio.h>

int main()
{
int x=10;
for(int i=0;i<5;i-=1)
int x=10,i;
for(i=0;i<5;i+=1)
{
int x=9;
printf("the value of x variable is %d",x);
printf("the value of x variable is %d\n",x);

}
return 0;
Expand Down
15 changes: 7 additions & 8 deletions author- RIYA SINGHAL(4).c
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@

#include <stdio.h>

int main()
{
int x=10;
for(int i=0;i<5;i-=1)//INFINITE LOOP
int x=10,i;
for(i=0;i<5;i+=1)
{
int x=9;
printf("the value of x variable is %d",x);
printf("the value of x variable is %d\n",x);

}
char x;//ALREADY DECLARED ABOVE
printf("enter any character");
scanf("%c",&x);
printf("the entered character is %c",x);
char xy;
printf("enter any character: ");
scanf("%c",&xy);
printf("the entered character is %c",xy);
return 0;
}
9 changes: 4 additions & 5 deletions author- RIYA SINGHAL(5).c
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#include <stdio.h>

int main()
{
int x=10;
for(int i=0;i<5;i-=1){
int x=9;
printf(x);}
int x=10,i;
for(i=0;i<5;i+=1){
x=9;
printf("%d",x);}
return 0;
}
6 changes: 4 additions & 2 deletions author-AKSHITA(1).c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ int main() {
int n1, n2, i, flag;
printf("Enter two positive integers: ");
scanf("%d %d", &n1, &n2);
printf("Prime numbers between %d and %d are: ", n1, n2)
printf("Prime numbers between %d and %d are: ", n1, n2);
for (i = n1 + 1; i < n2; ++i) {

// flag will be equal to 1 if i is prime
Expand All @@ -18,11 +18,13 @@ int main() {
// user-defined function to check prime number
int checkPrimeNumber(int n) {
int j, flag = 1;
if(n==1)
return 0;
for (j = 2; j <= n / 2; ++j) {
if (n % j == 0) {
flag = 0;
break;
}
}
return flag;
}
}
6 changes: 4 additions & 2 deletions author-AKSHITA(2).c
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ int main()
remainder=temp%10;
reverse_num=reverse_num*10+remainder;
temp/=10;
}
if(reverse_num==num)
printf("%d is a palindrome number",num);
else
print("%d is not a palindrome number",num);
printf("%d is not a palindrome number",num);

return 0;
}
}
8 changes: 4 additions & 4 deletions author-ALI RAZA.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# include <stdio.h>
void fun(int &x)
#include<stdio.h>
void fun(int* x)
{
*x = 30;
}

int main()
{
int y = 20;
fun(y);
printf("%d", *y);
fun(&y);
printf("%d", y);
return 0;
}

Expand Down
6 changes: 3 additions & 3 deletions author-ALWINDER(1).c
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
void fun(int *p)
{
int q = 10;
p = &*&q;
*p = &*&q;
}
int main()
{
int r = 20;
int *p = &*r;
int *p = &r; //p points to r
fun(p);
printf("%d", *&*&*p);
printf("%d", *&*&*p); //p now points to address of q
return 0;
}
5 changes: 3 additions & 2 deletions author-ALWINDER(2).c
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#include<stdio.h>
int main(){
char *ptr = "void pointer";
void *vptr;
int *vptr;
vptr = &ptr;
printf("%s" , **&(char **)vptr);
printf("%s" , **&vptr);
return 0;
}

2 changes: 1 addition & 1 deletion author-CHANDAN(1).c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ int main()
scanf("%d",&a);
printf("\nEnter value of b = ");
scanf("%d",&b);
sum=a+bsub=a-b;
sum=a+b;sub=a-b;
printf("\nSum: %d\nSub: %d",sum,sub);
return 0;
}
Expand Down
9 changes: 6 additions & 3 deletions author-GURSANGAT(1).c
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@ int main()
int i = 0;
for (i=0; i<20; i++)
{
switch(i);
switch(i)
{
case 0:
i += 5;
break;
case 1:
i += 2;
break;
case 5:
i += 5;
break;
default:
i += 4;
break;
}
printf("%c "; i);
printf("%d ", i);
}
return 0;
}
}
8 changes: 4 additions & 4 deletions author-GURSANGAT(2).c
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include<stdi0.h>
#include<stdio.h>

int main()
{
char ch;
int i;
scanf("%c", i);
scanf("%d", ch);
printf("%c %d", &ch, &i);
scanf("%c", &ch);
scanf("%d", &i);
printf("%c %d", ch, i);
return 0;
}
4 changes: 2 additions & 2 deletions author-HIYA MADAN(1).c
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ void main()
{
char str[20];
char *ptr=str,*temp;
int i=0,j;
int i=0,j,l;
scanf("%[^\n]",str);
while(*ptr)
{
i++;
ptr++;
}
for(j=0;j
for(j=0;j<i;j++)
{
if(*ptr==' ')
{
Expand Down
5 changes: 3 additions & 2 deletions author-HIYA MADAN(2).c
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
void main()
{

char *rev;
char rev[15];
char str[15];
scanf("%[^\n]",str);
int i,j;
for(i=strlen(str)-1,j=0;i>=0;i--,j++)
rev[j]=str[i];
{rev[j]=str[i];}
rev[j]='\0';
if(strcmp(rev,str))
printf("\nThe string is not a palindrome");
else
printf("\nThe string is a palindrome");
getch();
}
8 changes: 5 additions & 3 deletions author-JASKIRAT SINGH(1).c
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#include<stdio.h>

void transpose(int arr[][],int n)
void transpose(int arr[100][100],int n)
{
int tra[n][n],i,j;

for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
Expand All @@ -24,8 +25,8 @@ int main()
int n,i,j;
printf("Enter the order of matrix\n");
scanf("%d",&n);
int arr[n][n];
printf("Enter the elements");
int arr[100][100];
printf("Enter the elements:\n");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
Expand All @@ -42,4 +43,5 @@ int main()
}
printf("\n");
}
return 0;
}
3 changes: 2 additions & 1 deletion author-JASKIRAT SINGH(2).c
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#include<stdio.h>
int main()
{
int i=0;
int i=1;
for(;i!=0&&i<2;i++) //no change should be made in conditions and content of loop!!
{
printf("division");
}
printf("%d",5/i);
return 0;
}

9 changes: 5 additions & 4 deletions author-PALAK AGRAWAL(1).c
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#include <stdio.h>
int sum_arr(int arr[],int n);
int main()
{
int arr={23,45,132,90,345,1,45,8};
int sum=sum_arr(arr[],8);
printf("Sum=%d",sum);
int arr[]={23,45,132,90,345,1,45,8};
int sum=sum_arr(arr,8);
printf("Sum=%d",sum);
return 0;
}
int sum_arr(int arr[],int n)
{
int sum;
int sum=0,i;
for(i=0;i<n;i++)
{
sum=sum+arr[i];
Expand Down
19 changes: 12 additions & 7 deletions author-PALAK AGRAWAL(2).c
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
#include <stdio.h>
int isprime(int n)
{
int i,f,c;
for(i=0;i<n;i++)
int i,f,c=0;
for(i=2;i<n;i++)
{
if(n%c==0)
c++;
if(n%i==0)
c++;
}
if(c==2)
if(c==0)
{
f=1;
}
else
{
f=0;
}
return f;
}
int main()
{
int num;
printf("Enter a number:");
scanf("%d",num);
int r=isprime(num);
scanf("%d",&num);
if(num==1)
printf("1 is neither prime nor composite");
else
{int r=isprime(num);
if(r==1)
printf("%d is prime",num);
else
printf("%d is not prime",num);
}
}
7 changes: 4 additions & 3 deletions author-PRAGYA NAINWAL(1).c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include<stdio.h>
char* ReverseOfString(char *str1);
int main()
{
#define MAX 100
Expand All @@ -7,21 +8,21 @@ int main()
printf("------------------------------------------\n");

printf(" Input any string: ");
scanf("%s",&str1);
scanf("%s",str1);

revstr = ReverseOfString(str1);//call the function ReverseOfString

printf(" The reversed string is: %s\n\n",revstr);
return 0;
}
char ReverseOfString(char str1[])
char* ReverseOfString(char *str1)
{
static int i=0;
static char revstr[MAX];
if(*str1)
{
ReverseOfString(str1+1);//calling the function ReverseOfString itself
revstr[i=+1] = *str1;
revstr[i++] = *str1;
}
return revstr;
}
Expand Down
Loading