G

@Ganeshprabhu

Prime

C++
4 years ago
#include<iostream> using namespace std; class primeornot { int num, i, num1=0; public: void inputs() { cout<<"Enter a Number: "; cin>>num;

Armstrong

C++
4 years ago
#include <iostream> using namespace std; int main() { int n, r, temp, sum=0; cout <<"Enter the number "<<endl; cin>>n; temp =n; while(n>0) { r=n%10;

String

C++
4 years ago
#include <iostream> #include<string.h> using namespace std; int main() { char a[30],b[30]; cout <<"Enter your name "<<endl; cin>>a; strcpy(b,a); if(strcmp(a,b)==0)

Positive or negative

C++
4 years ago
#include <iostream> using namespace std; int main() { int num; cout<<"Enter the number"<<endl; cin>>num; if(num>0) cout <<"The given number "<<num<<" is positive "<<endl; else cout<<"The given number"<<num<<" is negative "<<endl;

Largest number

C++
4 years ago
#include <iostream> using namespace std; int main() { int a, b, c,large; cout <<"Enter the three numbers "; cin>>a>>b>>c; large =a>b?(a>c?a:c):(b>c?b:c); cout <<"\n"<<large <<" is largest number "; return 0;

Largest among threee

C++
4 years ago
#include <iostream> using namespace std; int main() { int a, b, c; cout<<"Enter the three numbers"; cin>>a>>b>>c; if (a>b&&a>c) cout <<"\n"<<a<<" is largest number"; else if (b>c) cout <<"\n"<<b<<" is largest number ";

Leap year or not

C++
4 years ago
#include <iostream> using namespace std; int main(){ int year; cout<<"Enter the year :"; cin>>year; if (year%4==0) cout <<"\n"<<year <<" is leap year "; else cout <<"\n"<<year <<" is not a leap year ";

Array

C
5 years ago
#include <stdio.h> int main() { int a[5],i; for (i=0;i<5;i++) { scanf ("%d",&a[i]); } printf ("The numbers are"); for (i=0;i<5;i++)

sum of even numbers

C
5 years ago
#include <stdio.h> int main() { int n=20,i,sum; printf ("Enter the number:%d\n",n); scanf ("%d\n",&n); for (i=0;i<=n;i+=2) sum+=i; printf ("sum of even numbers:%d\n",sum); return 0;

sum of n natural numbers

C
5 years ago
#include <stdio.h> int main() { int n=10,i,sum; printf ("Enter the number:%d\n",n); scanf ("%d\n",&n); for (i=1;i<=n;i++) sum+=i; printf ("sum of n natural numbers:%d\n",sum); return 0;

biggest of the three

C
5 years ago
#include <stdio.h> int main() { int num1,num2,num3; printf ("Enter the number1:",num1); scanf ("%d\n",&num1); printf ("%d\n",num1); printf ("Enter the number2:",num2); scanf ("%d\n",&num2); printf ("%d\n",num2);

sum of even numbers

C
5 years ago
#include <stdio.h> int main() { int n=20,i,sum; printf ("Enter the number:%d\n",n); for (i=0;i<=n;i+=2) sum+=i; printf ("sum of all even numbers:%d\n",sum);

sum and average

C
5 years ago
#include <stdio.h> int main() { int a,b,c,sum,avg; printf ("Enter the three numbers:",a,b,c); scanf ("%d%d%d",&a,&b,&c); printf ("%d\t%d\t%d\n",a,b,c); sum=a+b+c; avg=(a+b+c)/3; printf ("sum of three numbers:%d\n",sum);

Enum prog

C
5 years ago
#include <stdio.h> enum weak {mon=12,tues,wed,thurs,fri=7,sat,sun}; int main (){ printf ("The value of enum weak :%d\t%d\t%d\t%d\t%d\t%d",mon, tues, wed, thurs, fri, sat, sun); return 0; }

Swapping

C
5 years ago
#include <stdio.h> int main() { int first_no,second_no; printf ("Enter the first number:"); scanf ("%d",&first_no); printf ("%d\n",first_no); printf ("Enter the second number:"); scanf ("%d",&second_no); printf ("%d\n",second_no);

Sizeof prog

C
5 years ago
#include <stdio.h> int main() { int a; short int b; long int c; float d; double e; long double f; char g; printf ("size of int=%d bytes\n",sizeof (a));

Quo and rem

C
5 years ago
#include <stdio.h> int main() { int a, b, quo, rem; printf ("Enter the dividend : ",a); scanf ("%d",&a); printf ("%d\n",a); printf ("Enter the divisor :",b); scanf ("%d",&b);

Number system

C
5 years ago
#include <stdio.h> int main() { int num; printf ("Enter the value:",num); scanf ("%d",&num); printf ("%d\n",num); printf ("The decimal value is :%d\n",num); scanf ("%d",&num);

Ascii value

C
5 years ago
#include <stdio.h> int main() { char c='b'; int x=97; printf ("ASCII value of b=%d\n",c); printf ("ASCII character of 97=%c",x); return 0; }

Positive or not

C
5 years ago
#include <stdio.h> int main() { int x; printf ("enter a value x:",x); scanf ("%d",&x); printf ("%d\n",x); if (x>0) {