From da464a7f4e6d5440c22024f29e6c5734873ff471 Mon Sep 17 00:00:00 2001 From: Srijan Gupta Date: Thu, 24 Dec 2020 14:06:32 +0530 Subject: [PATCH] resolved all problems --- author- RIYA SINGHAL(1).c | 15 +++++++-------- author- RIYA SINGHAL(3).c | 7 +++---- author- RIYA SINGHAL(4).c | 15 +++++++-------- author- RIYA SINGHAL(5).c | 9 ++++----- author-AKSHITA(1).c | 6 ++++-- author-AKSHITA(2).c | 6 ++++-- author-ALI RAZA.c | 8 ++++---- author-ALWINDER(1).c | 6 +++--- author-ALWINDER(2).c | 5 +++-- author-CHANDAN(1).c | 2 +- author-GURSANGAT(1).c | 9 ++++++--- author-GURSANGAT(2).c | 8 ++++---- author-HIYA MADAN(1).c | 4 ++-- author-HIYA MADAN(2).c | 5 +++-- author-JASKIRAT SINGH(1).c | 8 +++++--- author-JASKIRAT SINGH(2).c | 3 ++- author-PALAK AGRAWAL(1).c | 9 +++++---- author-PALAK AGRAWAL(2).c | 19 ++++++++++++------- author-PRAGYA NAINWAL(1).c | 7 ++++--- author-PRAGYA NAINWAL(2).c | 15 +++++++-------- author-RIYA SINGHAL(2).c | 10 +++++----- author-SANCHAY JOSHI(1).c | 2 +- author-SANCHAY JOSHI(2).c | 4 ++-- author-SHIVAM MAHAJAN(1).c | 8 ++++---- author-SHIVAM MAHAJAN(2).c | 6 +++--- demo.c | 8 +++++--- 26 files changed, 110 insertions(+), 94 deletions(-) diff --git a/author- RIYA SINGHAL(1).c b/author- RIYA SINGHAL(1).c index 0cf263e..b8fb431 100644 --- a/author- RIYA SINGHAL(1).c +++ b/author- RIYA SINGHAL(1).c @@ -1,14 +1,13 @@ - #include 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; -} \ No newline at end of file +} diff --git a/author- RIYA SINGHAL(3).c b/author- RIYA SINGHAL(3).c index 0057de6..c1a5b9f 100644 --- a/author- RIYA SINGHAL(3).c +++ b/author- RIYA SINGHAL(3).c @@ -1,13 +1,12 @@ - #include 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; diff --git a/author- RIYA SINGHAL(4).c b/author- RIYA SINGHAL(4).c index 7ae8bb8..b72a44e 100644 --- a/author- RIYA SINGHAL(4).c +++ b/author- RIYA SINGHAL(4).c @@ -1,18 +1,17 @@ - #include 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; } diff --git a/author- RIYA SINGHAL(5).c b/author- RIYA SINGHAL(5).c index ba959fd..ff98c5f 100644 --- a/author- RIYA SINGHAL(5).c +++ b/author- RIYA SINGHAL(5).c @@ -1,10 +1,9 @@ #include - 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; } diff --git a/author-AKSHITA(1).c b/author-AKSHITA(1).c index 9d1b0e0..1a439c2 100644 --- a/author-AKSHITA(1).c +++ b/author-AKSHITA(1).c @@ -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 @@ -18,6 +18,8 @@ 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; @@ -25,4 +27,4 @@ int checkPrimeNumber(int n) { } } return flag; -} \ No newline at end of file +} diff --git a/author-AKSHITA(2).c b/author-AKSHITA(2).c index c0984f2..cc1d7aa 100644 --- a/author-AKSHITA(2).c +++ b/author-AKSHITA(2).c @@ -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; -} \ No newline at end of file +} diff --git a/author-ALI RAZA.c b/author-ALI RAZA.c index 665a17d..ce65966 100644 --- a/author-ALI RAZA.c +++ b/author-ALI RAZA.c @@ -1,5 +1,5 @@ -# include -void fun(int &x) +#include +void fun(int* x) { *x = 30; } @@ -7,8 +7,8 @@ void fun(int &x) int main() { int y = 20; - fun(y); - printf("%d", *y); + fun(&y); + printf("%d", y); return 0; } diff --git a/author-ALWINDER(1).c b/author-ALWINDER(1).c index 77b51f5..6c8c5e7 100644 --- a/author-ALWINDER(1).c +++ b/author-ALWINDER(1).c @@ -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; } diff --git a/author-ALWINDER(2).c b/author-ALWINDER(2).c index 8a09f7e..bbff6b1 100644 --- a/author-ALWINDER(2).c +++ b/author-ALWINDER(2).c @@ -1,8 +1,9 @@ #include int main(){ char *ptr = "void pointer"; - void *vptr; + int *vptr; vptr = &ptr; - printf("%s" , **&(char **)vptr); + printf("%s" , **&vptr); return 0; } + diff --git a/author-CHANDAN(1).c b/author-CHANDAN(1).c index d2f53db..7176d67 100644 --- a/author-CHANDAN(1).c +++ b/author-CHANDAN(1).c @@ -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; } diff --git a/author-GURSANGAT(1).c b/author-GURSANGAT(1).c index 1faf009..739e6ba 100644 --- a/author-GURSANGAT(1).c +++ b/author-GURSANGAT(1).c @@ -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; -} \ No newline at end of file +} diff --git a/author-GURSANGAT(2).c b/author-GURSANGAT(2).c index 2695849..464ee1e 100644 --- a/author-GURSANGAT(2).c +++ b/author-GURSANGAT(2).c @@ -1,11 +1,11 @@ -#include +#include 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; } diff --git a/author-HIYA MADAN(1).c b/author-HIYA MADAN(1).c index 3c7110f..f10eca3 100644 --- a/author-HIYA MADAN(1).c +++ b/author-HIYA MADAN(1).c @@ -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=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(); } diff --git a/author-JASKIRAT SINGH(1).c b/author-JASKIRAT SINGH(1).c index 9cd43ba..13c6b92 100644 --- a/author-JASKIRAT SINGH(1).c +++ b/author-JASKIRAT SINGH(1).c @@ -1,8 +1,9 @@ #include -void transpose(int arr[][],int n) +void transpose(int arr[100][100],int n) { int tra[n][n],i,j; + for(i=0;i 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"); @@ -9,3 +9,4 @@ int main() printf("%d",5/i); return 0; } + diff --git a/author-PALAK AGRAWAL(1).c b/author-PALAK AGRAWAL(1).c index 30746ac..11a4dac 100644 --- a/author-PALAK AGRAWAL(1).c +++ b/author-PALAK AGRAWAL(1).c @@ -1,14 +1,15 @@ #include +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 int isprime(int n) { - int i,f,c; - for(i=0;i +char* ReverseOfString(char *str1); int main() { #define MAX 100 @@ -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; } diff --git a/author-PRAGYA NAINWAL(2).c b/author-PRAGYA NAINWAL(2).c index b7580be..4466065 100644 --- a/author-PRAGYA NAINWAL(2).c +++ b/author-PRAGYA NAINWAL(2).c @@ -1,22 +1,21 @@ #include //Function to calculate the maximum sum of a sub-array of a given array -void maxSumarray(int a, int size){ +int maxSumarray(int a[], int size){ int i; int max_sum_so_far=0; int max_ending_here = 0; - for(i=0,i -int Main() +int main() { - int x,y; - Printf("enter the no. to be divided"); + int x,y,i; + printf("enter the no. to be divided"); scanf("%d",&x); - for(int i=1;i<=5;i+=1); + for(i=1;i<=5;i+=1) { - x+i=y; + y=x+i; printf("\n the sum of given number with %d is %d",i,y); } return 0; diff --git a/author-SANCHAY JOSHI(1).c b/author-SANCHAY JOSHI(1).c index d32200e..18d0498 100644 --- a/author-SANCHAY JOSHI(1).c +++ b/author-SANCHAY JOSHI(1).c @@ -2,7 +2,7 @@ int gcd(int a,int b) { - if(b < 0) + if(b <= 0) return a; else return gcd(b,a%b); diff --git a/author-SANCHAY JOSHI(2).c b/author-SANCHAY JOSHI(2).c index d180938..b379780 100644 --- a/author-SANCHAY JOSHI(2).c +++ b/author-SANCHAY JOSHI(2).c @@ -2,8 +2,8 @@ int main() { - int var = 2147483648; + unsigned int var = 2147483648; printf("Sanchay\n\n"); - printf("Value of var = %d\n",var); + printf("Value of var = %u\n",var); return 0; } diff --git a/author-SHIVAM MAHAJAN(1).c b/author-SHIVAM MAHAJAN(1).c index b7ef31e..e1b26b7 100644 --- a/author-SHIVAM MAHAJAN(1).c +++ b/author-SHIVAM MAHAJAN(1).c @@ -21,13 +21,13 @@ void main() { if (arr1[i]%2 == 0) { - arr2[i] = arr1[j]; - i++; + arr2[j] = arr1[i]; + j++; } else { - arr3[i] = arr1[k]; - i++; + arr3[k] = arr1[i]; + k++; } } diff --git a/author-SHIVAM MAHAJAN(2).c b/author-SHIVAM MAHAJAN(2).c index f39e39a..10ccda9 100644 --- a/author-SHIVAM MAHAJAN(2).c +++ b/author-SHIVAM MAHAJAN(2).c @@ -19,11 +19,11 @@ void main(){ sum = 0; while(temp!=0){ - r=temp / 10; - temp%=10; + r=temp%10; sum=sum + pow(r,3); + temp/=10; } - if(sum=num) + if(sum==num) printf("%d ",num); } printf("\n"); diff --git a/demo.c b/demo.c index 7921b6f..510962b 100644 --- a/demo.c +++ b/demo.c @@ -2,7 +2,9 @@ void main(){ int i=0; - for(printf("hello world");i<10;i++){ - printf("hello world"); + for(printf("hello world");i<10;i++) + { + printf("hello world\n"); } -} \ No newline at end of file + +}