Bap: a beta jara bol to kis boys cricket team captan larki?
Beta: a kase hoga larka team main captan larki?? A nehi ho sakta.
Bap: abe hain . jara soch ke bata.
Beta: mujhe to bakwas lagta he.
Bap: Srilanka ki us team ki captan “Mahila Joyabardhana
#include<stdio.h> main() { int n; printf("Enter an integer\n"); scanf("%d",&n); if ( n%2 == 0 ) printf("Even\n"); else printf("Odd\n"); return 0; }
#include<stdio.h> main() { int n; printf("Enter an integer\n"); scanf("%d",&n); if ( n & 1 == 1 ) printf("Odd\n"); else printf("Even\n"); return 0; }
#include<stdio.h> main() { int n; printf("Enter an integer\n"); scanf("%d",&n); if ( (n/2)*2 == n ) printf("Even\n"); else printf("Odd\n"); return 0; }
#include<stdio.h> main() { int n; printf("Enter an integer\n"); scanf("%d",&n); n%2 == 0 ? printf("Even number\n") : printf("Odd number\n"); return 0; }
#include <stdio.h> main() { int n, c, k; printf("Enter an integer in decimal number system\n"); scanf("%d",&n); printf("%d in binary number system is:\n", n); for ( c = 31 ; c >= 0 ; c-- ) { k = n >> c; if ( k & 1 ) printf("1"); else printf("0"); } printf("\n"); return 0; }
#include <stdio.h> #include <stdlib.h> char *decimal_to_binary(int); main() { int n, c, k; char *pointer; printf("Enter an integer in decimal number system\n"); scanf("%d",&n); pointer = decimal_to_binary(n); printf("Binary string of %d is: %s\n", n, t); free(pointer); return 0; } char *decimal_to_binary(int n) { int c, d, count; char *pointer; count = 0; pointer = (char*)malloc(32+1); if ( pointer == NULL ) exit(EXIT_FAILURE); for ( c = 31 ; c >= 0 ; c-- ) { d = n >> c; if ( d & 1 ) *(pointer+count) = 1 + '0'; else *(pointer+count) = 0 + '0'; count++; } *(pointer+count) = '\0'; return pointer; }
#include<stdio.h> #include<conio.h> #include<stdlib.h> struct complex { int real; int img; }; main() { struct complex a, b, c; printf("Enter a and b where a + ib is the first complex number."); printf("\na = "); scanf("%d", &a.real); printf("b = "); scanf("%d", &a.img); printf("Enter c and d where c + id is the second complex number."); printf("\nc = "); scanf("%d", &b.real); printf("d = "); scanf("%d", &b.img); c.real = a.real + b.real; c.img = a.img + b.img; if ( c.img >= 0 ) printf("Sum of two complex numbers = %d + %di",c.real,c.img); else printf("Sum of two complex numbers = %d %di",c.real,c.img); getch(); return 0; }
#include<stdio.h> #include<conio.h> main() { int c, n, fact = 1; printf("Enter a number to calculate it's factorial\n"); scanf("%d",&n); for( c = 1 ; c <= n ; c++ ) fact = fact*c; printf("Factorial of %d = %d\n",n,fact); getch(); return 0; }
#include<stdio.h> long factorial(int); main() { int number; long fact = 1; printf("Enter a number to calculate it's factorial\n"); scanf("%d",&number); printf("%d! = %ld\n", number, factorial(number)); return 0; } long factorial(int n) { int c; long result = 1; for( c = 1 ; c <= n ; c++ ) result = result*c; return ( result ); }
#include<stdio.h> long factorial(int); main() { int num; long f; printf("ENTER A NUMBER TO FIND FACTORIAL :"); scanf("%d",&num); if(num<0) printf("NEGATIVE NUMBERS ARE NOT ALLOWED"); else { f = factorial(num); printf("%d!=%ld",num,f); } return(0); } long factorial(int n) { if(n==0) return(1); else return(n*factorial(n-1)); }
#include<stdio.h> #include<string.h> main() { char a[100], b[100]; printf("Enter the first string\n"); gets(a); printf("Enter the second string\n"); gets(b); if( strcmp(a,b) == 0 ) printf("Entered strings are equal.\n"); else printf("Entered strings are not equal.\n"); return 0; }
int compare(char a[], char b[]) { int c = 0; while( a[c] == b[c] ) { if( a[c] == '\0' || b[c] == '\0' ) break; c++; } if( a[c] == '\0' && b[c] == '\0' ) return 0; else return -1; }
#include<stdio.h> int compare_string(char*, char*); main() { char first[100], second[100], result; printf("Enter first string\n"); gets(first); printf("Enter second string\n"); gets(second); result = compare_string(first, second); if ( result == 0 ) printf("Both strings are same.\n"); else printf("Entered strings are not equal.\n"); return 0; } int compare_string(char *first, char *second) { while(*first==*second) { if ( *first == '\0' || *second == '\0' ) break; first++; second++; } if( *first == '\0' && *second == '\0' ) return 0; else return -1; }
#include<stdio.h> #include<conio.h> main() { int x, y, temp; printf("Enter the value of x and y "); scanf("%d%d",&x, &y); printf("Before Swapping\nx = %d\ny = %d\n",x,y); temp = x; x = y; y = temp; printf("After Swapping\nx = %d\ny = %d\n",x,y); getch(); return 0; }
#include<stdio.h> main() { int a, b; printf("Enter two numbers to swap "); scanf("%d%d",&a,&b); a = a + b; b = a - b; a = a - b; printf("a = %d\nb = %d\n",a,b); return 0; }
#include<stdio.h> main() { int x, y, *a, *b, temp; printf("Enter the value of x and y "); scanf("%d%d",&x,&y); printf("Before Swapping\nx = %d\ny = %d\n", x, y); a = &x; b = &y; temp = *b; *b = *a; *a = temp; printf("After Swapping\nx = %d\ny = %d\n", x, y); return 0; }
#include<stdio.h> void swap(int*, int*); main() { int x, y; printf("Enter the value of x and y\n"); scanf("%d%d",&x,&y); printf("Before Swapping\nx = %d\ny = %d\n", x, y); swap(&x, &y); printf("After Swapping\nx = %d\ny = %d\n", x, y); return 0; } void swap(int *a, int *b) { int temp; temp = *b; *b = *a; *a = temp; }
#include<stdio.h> #include<conio.h> main() { int n, sum = 0, c, var; printf("Enter the number of integers you want to add\n"); scanf("%d",&n); printf("Enter %d numbers\n",n); for ( c = 1 ; c <= n ; c++ ) { scanf("%d",&var); sum = sum + var; } printf("Sum of entered numbers = %d\n",sum); getch(); return 0; }