V

@vanshu_179

print the sum of first n natural no. also print them in reverse

C
3 years ago
#include <stdio.h> int main() { int n; printf("enter a no. \n"); scanf("%d \n",&n); int sum=0; for (int i=1, j=n; i<=n && j>=1; i++, j--) {

print the sum of first n natural no. also print them in reverse

C
3 years ago
#include <stdio.h> int main() { int n; printf("enter a no. \n"); scanf("%d \n",&n); int sum=0; int i; for (i=1;i<=n;i++)

print the sum of first n natural no.

C
3 years ago
#include <stdio.h> int main() { int n; printf("enter a no. \n"); scanf("%d \n",&n); int sum=0; int i; for (i=1;i<=n;i++)

do while loop

C
3 years ago
#include <stdio.h> int main() { int i=10; do { printf("Hello world!\n"); i--; } while (i>=5); return 0; }

do while loop

C
3 years ago
#include <stdio.h> int main() { int i=2; do { printf("Hello world!\n"); i++; } while (i<=5); return 0; }

print the no. from 0 to n,if n is given by user

C
3 years ago
#include <stdio.h> int main() { int n; printf("enter a no. \n"); scanf("%d", &n); /* int i=0; while (i<=n){ printf("%d \n",i); i++;} */

print hello world using while loop

C
3 years ago
#include <stdio.h> int main() { int i=1; while (i<=20){ printf("Hello world!\n"); i++; } return 0; }

program for infinite loops

C
3 years ago
#include <stdio.h> int main() { int i; for (i=1; ;i++) printf("Hello world!\n"); return 0; }

program for float and ch using for loop

C
3 years ago
#include <stdio.h> int main() { /* float i; for( i=1.0 ;i<=5.0 ;i++) { printf("%f \n",i);} where i is iterator or counter */ char ch; for(ch= 'a';ch<='z';ch++)

increment and decrement operators

C
3 years ago
#include <stdio.h> int main() { int i= 1 ; /* printf("%d \n",i++); printf("%d",i); i++ post increment,i.e use i then increase */ //printf("%d \n",++i); // printf("%d", i);

print the no. from 0 to 10

C
3 years ago
#include <stdio.h> int main() { int i; for (i = 0; i <= 10; i = i+1) printf("%d \n",i); return 0; } // i=i+1 or i+=1 or i++ all are same

character is uppercase or not

C
3 years ago
#include <stdio.h> int main() { char ch; printf("enter character \n"); scanf(" %c", &ch); if ( ch >= 'a' && ch <= 'z') { printf(" lowercase "); } else if ( ch >= 'A' && ch <= 'Z') { printf(" uppercase");}

grades

C
3 years ago
#include <stdio.h> int main() { int marks; printf("enter marks \n"); scanf(" %d", &marks); if (marks <30){ printf(" C"); }else if (30 <= marks < 70 ) { printf (" B ");

wap to check if a student passed or fail marks>30-pass & marks<30-fail using ternary operation

C
3 years ago
#include <stdio.h> int main() { int marks; printf("enter marks(0-100) \n"); scanf("%d", &marks ); marks >=30 ? printf("pass \n"): printf("fail \n"); return 0; }

wap to check if a student passed or fail marks>30-pass & marks<30-fail

C
3 years ago
#include <stdio.h> int main() { int marks; printf("enter marks(0-100) \n"); scanf("%d", &marks ); if (marks <= 30){ printf ("fail\n"); }

if a no. is greater than 9 & smaller than 100 (2 digit no.) then print true

C
3 years ago
#include <stdio.h> int main() { int x; printf("enter a number \n"); scanf("%d", &x); printf("%d", x >9 && x<100); return 0; }

if it's monday and it's raining then print true

C
3 years ago
#include <stdio.h> int main() { int isMonday=1; int isRaining=0; printf("%d\n", isMonday || isRaining); return 0; }

if it's sunday and it's snowing then print true

C
3 years ago
#include <stdio.h> int main() { int isSunday=1; int isSnowing=1; printf("%d \n",isSunday && isSnowing); return 0; }

a no. is even or odd

C
3 years ago
#include <stdio.h> int main() { int x; printf("enter a number \n"); scanf("%d", &x); if (x % 2 == 0) { printf("the number is even" ); }

a no. is divisible by 2 or not

C
3 years ago
#include <stdio.h> int main() { int x; printf("enter a number \n"); scanf("%d", &x); printf(" %d", x % 2 == 0); return 0; }