assignmentsn needed about for loop in c++
assignmentsn needed about for loop in c++
ma ishq-e-kainaat ma zanjeer ho saku
mujh ko hisar-e-zaat ke shar se rahai de
Assignment to aap ko khud karni chahye!
Aap ko assignment chahye! lekin loop se related koi question to hoga!
C++ main to Do-While, While aor For loop hain, aap konsi loop ki baat kar rahay hain!
mujh ko for loop se related questions chahie for practice yar
questions
1. user will enter a number and check that number is prime or not prime.
2. enter a number and prints its table.
3. print this shape on screen
*
**
***
****
*****
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int num,sum,i,counter=1;
cout<<"enter the intiger which u want table (1 to 20)=";
cin>>num;
if(num>0&&num<20)
for(i=1;i<=10;i++)
{
sum=num*i;
cout<<num<<"*"<<i<<"="<<sum<<endl;
counter++;
}
else
cout<<"invalid";
getch();
}
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int n,i,divisioncount=0;
cout<<"enter the number";
cin>>n;
for(i=2;i<=n/2;i++)
if(n%i==0)
divisioncount++;
if(divisioncount!=0)
cout<<"not prime\n"<<"divisble by=" <<divisioncount;
else
cout<<" prime";
getch();
}
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int num,row,column;
cout<<"enter the intiger="<<endl;
cin>>num;
for (row = 1; row<=num; row++)
{
for (column= 1; column<=num; column++)
{
if (column<=row)
cout<< "*";
else
cout<< " ";
cout<<endl; }
}
getch();
}
yar 3rd wla sahi nae hai help karo output aik hi column ma show ho rahi ha
Ye lijye:
Code:#include<iostream.h> #include<conio.h> void main() { clrscr(); int num,row,column; cout<<"Eenter the integer:? "; cin>>num; for (row = 1; row<=num; row++) { for (column= 1; column<=num; column++) { if (column<=row) cout<< "*"; else cout<< " "; column++; } column=1; row++; cout<<endl; } getch(); }
Here is the program, check whether number is Palindromic or not:
Code:#include<iostream.h> #include<conio.h> void main(){ int num,r,sum=0,tmp; clrscr(); cout << "Enter a number:? "; cin >> num; tmp=num; while(num){ r=num%10; num=num/10; sum=sum*10+r; } if(tmp==sum) cout << tmp << " is a palindrome."; else cout << tmp << " is not a palindrome."; getch(); }
Bookmarks