C C C C

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

#include<iostream.h> #include<conio.h> #include<stdio.h> #include<math.

h> void main() { int number,sron; clrscr(); cout<<"enter a number to check whether its prime or not"; cin>>number; sron=sqrt(number); for(int i=2;i<=sron;i++) { if(number%i==0) { cout<<endl<<number<<" is not a prime number"; break; } else { cout<<endl<<number<<" is a prime number"; break; } } getch(); }

#include<iostream.h> #include<conio.h> #include<stdio.h> void main() { clrscr(); int num1,num2,temp=0; cout<<"enter two numbers"; cin>>num1>>num2; cout<<endl<<"numbers before swaping"; cout<<endl<<num1<<" "<<num2; getch(); temp=num1; num1=num2; num2=temp; cout<<endl<<"numbers after swaping"; cout<<endl<<num1<<" "<<num2; getch(); }

#include<iostream.h> #include<conio.h> #include<stdio.h> #include<string.h> void main() { clrscr(); char str1[100],str2[100]; cout<<"enter first string"; gets(str1); cout<<endl<<"enter second string"; gets(str2); strcat(str1,str2); cout<<endl<<"the string after concatenation is:"; cout<<endl<<str1; getch(); }

#include<iostream.h> #include<conio.h> void main() { clrscr(); int a[10][10],m,n,i,j; cout<<"Enter number of rows: "; cin>>m; cout<<"Enter number of coloumns: "; cin>>n; if(m!=n) { cout<<"Matrix not square so Transpose not possible :("; } else { cout<<endl<<"Enter elements of matrix: "<<endl; for(i=0;i<m;i++) { for(j=0;j<n;j++) { cout<<"Enter element a"<<i+1<<j+1<<": "; cin>>a[i][j]; } } cout<<endl<<"Displaying Matrix: "<<endl<<endl; for(i=0;i<m;i++) { for(j=0;j<n;j++) { cout<<a[i][j]<<" "; } cout<<endl<<endl; } cout<<endl<<"Displaying Matrix Transpose: "<<endl<<endl; for(i=0;i<m;i++) { for(j=0;j<n;j++) { cout<<a[j][i]<<" "; } cout<<endl<<endl; } } getch(); }

#include<iostream.h> #include<stdio.h> #include<conio.h> #include<string.h> void main() { clrscr(); char str[100]; int ch,num,vowels,spc,strln,consonants; ch=num=vowels=spc=0; cout<<"Enter the string: "; gets(str); strln=strlen(str); for(int i=0;str[i]!='\0';i++) { if((str[i]>=65&&str[i]<=90||str[i]>=97&&str[i]<=122)) ch++; if(str[i]>=48&&str[i]<=57) num++; if(str[i]=='a'||str[i]=='e'||str[i]=='i'||str[i]=='o'||str[i]=='u'||str[i]=='A'||str[i]=='E'||str[i]=='I'|| str[i]=='O'||str[i]=='U') vowels++; if(str[i]==' ') spc++; } consonants=ch-vowels; cout<<endl<<endl<<"No. of vowels: "<<vowels; cout<<endl<<endl<<"No. of consonants: "<<consonants; cout<<endl<<endl<<"No. of digits: "<<num; cout<<endl<<endl<<"No. of words: "<<(spc+1); cout<<endl<<endl<<"No of specal character: "<<(strln-ch-num-spc); getch(); }

#include <iostream.h> #include<stdio.h> #include <ctype.h> #include <conio.h> void main() { clrscr(); char sentence[100]; int count, ch, i; cout<<"Enter a sentence: "; for(i=0; (sentence[i] = getchar())!='\n'; i++) { ; } count=i; cout<<endl<<endl<<"Input sentence is: "<<sentence; cout<<endl<<endl<<"Resultant sentence is: "; for(i=0; i < count; i++) { ch = islower(sentence[i]) ? toupper(sentence[i]) : tolower(sentence[i]); putchar(ch); } getch(); }

You might also like