Posts

Showing posts from July, 2021

wwrite a program to enter number of digits and form a number using these digits.

Image
#include<stdio.h> #include<math.h> int main() { int n,i,a[10],s=0; printf("enter the no of digit "); scanf("%d",&n); for(i=0;i<n;i++) { printf("enter the %d th digit ",i); scanf("%d",&a[i]); } i=0; while(i<n) { s=s+a[i]*pow(10,i); i++; } printf("the no is %d",s); return 0; }  

write a program to concatenate two string without using stract().

Image
#include<stdio.h> #include<conio.h> int main() { char str1[50],str2[50],i,j; printf("enter first string\n"); scanf("%s",&str1); printf("enter second string\n"); scanf("%s",&str2); for(i=0;str1[i]!='\0';i++); for(j=0;str2[j]!='\0';j++,i++) { str1[i]=str2[j]; } str1[i]='\0'; printf("\n output is %s",str1); return 0; }  

write a program to find

Image
#include<stdio.h> #include<conio.h> int main() { int a; printf("enter no between 1 to 5:"); scanf("%d",&a); switch(a) { case 1: { printf("hello"); } break; case 2: { printf("abhishek"); } break; case 3: { printf("bro"); } break; case 4: { printf("how are you"); } break; default: printf("error found⚠️⚠️"); } return 0; }

write a program to find whether a character is vowel or not by using switch case .

Image
#include<stdio.h> #include<conio.h> int main() { char ch; printf("enter a character:"); scanf("%c",&ch); switch(ch) { case 'a': case 'e': case 'i': case 'o': case 'u': printf("%c is  vowel",ch); break; default: printf("%c is not vowel",ch); break; } return 0; }

write a program to create a calculator using switch case.

Image
#include<stdio.h> #include<conio.h> int main() { int a,b; char operator; printf("enter operator(+,-,*,/):"); scanf("%c",&operator); printf("enter two number"); scanf("%d%d",&a,&b); switch(operator) { case '+': printf("%d",a+b); break; case '-': printf("%d",a-b); break; case '*': printf("%d",a*b); break; case '/': printf("%d",a/b); break; default: printf("error danger⚠️⚠️⚠️ 😭😭"); break; } return 0; }

write a program to print pattern(pyramid) for inverted half pyramid.

Image
#include<stdio.h> #include<conio.h> int main() { int i,j,n; printf("enter the number "); scanf("%d",&n); for(i=n;i>=1;i--) { for(j=1;j<=i;j++) { printf("🔥"); } printf("\n"); } return 0; }

write a program to print half pyramid(pattern).

Image
#include<stdio.h> #include<conio.h> int main() { int i,j,n; printf("enter the number "); scanf("%d",&n); for(i=1;i<=n;i++) { for(j=1;j<=i;j++) { printf("🔥"); } printf("\n"); } return 0; }