C language interview questions solution for freshers beginners placement tricky good pointers answers explanation operators data types arrays structures functions recursion preprocessors looping file handling strings switch case if else printf advance linux objective mcq faq online written test prime numbers Armstrong Fibonacci series factorial palindrome code programs examples on c++ tutorials and pdf
82 comments:
pls give us some examples regarding pyramids..such as
a
1 2
b c d
3 4 4 6
#include
int main(){
int i,j;
i=0;
while(i<5);
{
printf("*");
}
j=0;
while(j<5);
{ printf("*");
j++;
}
i++;
return 0;
} what abt this
in this lesson Question 9,10 answers r nt working.. compiler tells that undefined reference to `pow' .. how we should define that pow in C?????
Hi s.m. dilhari,
I think you are using Linux gcc compiler. If yes, I hope this link will help you:
http://cquestionbank.blogspot.com/2010/07/undefined-reference-to-pow-collect2-ld.html
Use header in the program
I think you are using Linux gcc compiler. If yes, I hope this link will help you:
http://cquestionbank.blogspot.com/2010/07/undefined-reference-to-pow-collect2-ld.html
can you possibly give a way to print a sideways diamond?
write a program for
* *
** **
*** ***
*******
how to print a heart using asterix(*)
write a programm that this is the output:
000001
000010
000100
001000
010000
100000
int main()
{
int i,j,n=6;
clrscr();
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
if((i+j)==(n+1))
printf("1");
else
printf("0");
}
printf("\n");
}
getch();
return 0;
}
Please help me to WRITE A PROGRAM SIMILAR TO THE PRIME NUMBER TESTER,EXCEPT THAT IT DISPLAY'S ALL THE FACTORS OF A NUMBER ENTERED BY THE USER,FOR EXAMPLE IF A USER ENTERED IT WOULD RESPONSE WITH 2 AND 4
it is too easy to write c coding for different shapes like circle etc
but how you can write a c code for circle and display it by using function
getch(); or getche();
sir in 3 rd question ur answer is wrong put i=2
after run program..
regards tanuj
for any query email me (tanujkhurana83@gmail.com)
pls send me de solution manual of computer science :A structured programming approach using c by Behrouz A Forouzan as soon as possible to my id surabhisreess@gmail.com
i didnt get this expression ,plz explain it clearly..
for(i=0;i<5;i++){
printf("%*.*s\n",i,i,c);
#include
#include
void main()
{
int i,j;
int k=5;
for(i=0;i<6;i++)
{for(j=0;j<6;j++)
{
if(j!=k)
printf("0");
else {printf("1");
k--;}
}printf("\n");}
}
pls give solution for ths
write a program to print the following output
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
int main()
{
int i,j;
for(i=1;i<=5;i++){
for(j=1;j<=i;j++){
printf("%d",i);
}
printf("\n");
}
return 0;
}
many of programs are not execute.......
# # #
####
# #
code for this program ???
pls give solution for ths
write a program to print the following output
1
3 2
4 5 6
10 9 8 7
int main ()
{
int n=16,i,j,k;
for (i=1,k=1;i<=n;i++,k++)
{
for (j=1;j<=i+k;j++)
{
printf ("* ");
}
printf ("\n");
}
}
* *
* * * *
* * * * * *
* * * * * * * *
* * * * * * * * * *
* * * * * * * * * * * *
* * * * * * * * * * * * * *
* * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
how to print an E shaped program in c
Short version:
#include
int i;
main()
{
for (i=1;i<=5;i++){
if (i/2*2!=i)
printf("%s","*****");
else
printf("%s","*");
printf("%s","\n");
}
}
Long Version (bigger)
#include
int i, j;
main()
{
for (i=1;i<=10;i++){
if ((i-1)%4<=1){
for (j=1;j<=8;j++)
printf("%s","*");
} else {
for (j=1;j<=2;j++)
printf("%s","*");
}
printf("%s","\n");
}
}
Complex versoin:
#include
int i, j;
main()
{
for (i=1;i<=10;i++){
switch (i){
case 1:
case 10:
for (j=1;j<=10;j++)
printf("%s","*");
break;
case 2:
case 9:
printf("%s"," *");
for (j=1;j<=7;j++)
printf("%s"," ");
printf("%s","*");
break;
case 5:
case 6:
printf("%s"," ");
for (j=1;j<=8;j++)
printf("%s","*");
break;
default:
printf("%s"," *");
break;
}
printf("%s","\n");
}
}
#include
int i, j, k;
main()
{
k = 0;
for (i=1;i<=4;i++){
k+=i;
if (i%2) {
for (j=k-i+1;j<=k;j++)
printf("%d ",j);
} else {
for (j=k;j>=k-i+1;j--)
printf("%d ",j);
}
printf("%s","\n");
}
}
main()
{
for (i=1;i<=5;i++){
for (j=1;j<=i;j++)
printf("%d ",i);
printf("%s","\n");
}
}
#include
#include
void main()
{
int i,j;
clrscr();
for(i=1;i<=16;i++)
{
for(j=1;j<=2*i;j++)
printf("*");
printf("\n");
}
getch();
}
how to print X shaped program
How about a Checkerboard effect using * in C
Hi,
If I take n as input from user what will be the code?
The shape same as answer no. 17 .How should I write the code ?
Thanks
pls give solution for ths
write a program to print the following output
1
6 2
10 7 3
13 11 8 4
15 14 12 9 5
int i,j;
for(;i++<10;printf("\n"))for(j=0;j++<10;i!=j&&i+j!=11?printf(" "):printf("*"));
assume a number under 2 digits
#include
int main(){
char a[3];int i,j,k;
while(!k){
fgets(a, sizeof a, stdin);
sscanf(a, "%2d", &k);
} //input part done
for (;i++k-i&&j<k+i?'*':' ');
}
With prompting of size
#include
int main(){
char a[3];int i,j,k;
while(!k){
fgets(a, sizeof a, stdin);
sscanf(a, "%2d", &k);
} //input part done
for (;i++<k;printf("\n")) for (j=0;j++<k;) printf("%c", (i+j)%2?'*':' ');
}
plot some functions.
#include
int main(){
char a[3];int i,j,k,O;
while(!k){
fgets(a, sizeof a, stdin);
sscanf(a, "%d", &k);
} //input part done
for (;i++<k;printf("\n\n")) for (j=0;j++<k;O<0?:printf("%d ",O)) O=j-1-k+((2*k-(i-j)+2)*(i-j+1))/2;
}
remove spaces in actual diamond
#include
int main()
{
int ch=97,i,n,j,k,z;
printf("Enter the number of lines");
scanf("%d",&n);
for(i=0,z=1;i<n/2;i++)
{
for(j=0;j<i;j++)
{
printf("%c ",ch);
}
printf("\n");
for(k=0;k<j;k++,z++)
{
printf("%d ",z);
}
printf("\n");
}
return 0;
}
#include
int main()
{
int i,j,k,n;
printf("Enter the no.of lines");
scanf("%d",&n);
for(i=0;i<n;i++)
{
for(j=0;j<i;j++)
{
printf("*");
}
printf(" ");
for(k=0;k<i;k++)
{
printf("*");
}
printf(" ");
printf("\n");
}
return 0;
}
Please anyone explain this program how it works ..
#include
int main()
{
int i,n,j,k;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(k=n;k>i;k--)//for space print.//
{
printf(" ");
}
for(j=1;j<=10;j++)//for number print in every row//
{
if(j<i)
continue;
if(j==2*i-1)
printf("%d",j);
else
if(j<2*i-1)
printf("%d ",j);
else break; }
printf("\n");
}
return 0;
}
Can anyone tell me how to display X-shape pattern using nested loops in C (not C++). ASAP
Plz give me this pattern answer
*
**
***
**
*
Plz give me this pattern answer
*
**
***
**
*
Plz give me this pattern answer
*
**
***
**
*
Plz give me this pattern answer
************
************
************
************
************
************
************
************
************
************
************
************
Plz give me answer of this pattern
************
************
************
************
************
************
************
************
************
************
************
************
1 1
2 2
3 3
4
3 3
2 2
1 1
how can I print these No in X pattren
1 1
2 2
3 3
4
3 3
2 2
1 1
how can I print these No in X pattren
SSSSS
S. S
S. S
S. S
SSSSS
I NEED A PROGRAM FOR THIS OUT PUT.PLESE
SSSSS
S. S
S. S
S. S
SSSSS
I NEED A PROGRAM FOR THIS OUT PUT.PLESE
1
1
2
12
3
123
4
1234
1
1
2
12
3
123
4
1234
I want c code for the following output , if am give input 15,plz help me
7 6 5
8 1 4 15
9 2 3 14
10 11 12 13
int main()
{
int i,j,n;
printf("enter number ");
scanf(" %d",&n);
for(i=1;i<=n;i++)
{
printf ("\n%d\n",i);
for(j=1;j<=i;j++)
printf("%2d", j);
}
return 0;
}
int main()
{
int i,j,n;
printf("enter number ");
scanf(" %d",&n);
for(i=1;i<=n;i++)
{
printf ("\n%d\n",i);
for(j=1;j<=i;j++)
printf("%2d", j);
}
return 0;
}
I want c code for the following output , if am give input 15,plz help me
7 6 5
8 1 4 15
9 2 3 14
10 11 12 13
Write the class named parallelogram which has a function display() that is started below. A call of parallelogram::display (6, 5) produces a parallelogram with 6 rows of 5 stars in the following shape:
*****
*****
*****
*****
*****
*****
void parallelogram ::display (int iRows, int iCols)
Any One?????????
a program that accepts a number any integer less than 1 and has 8 digits maximum
example
Please enter a number:12345
1
12
123
1234
12345
2345
345
45
5
I need this programm:
https://moodle.hitsa.ee/pluginfile.php/1112932/mod_assign/intro/v.jpg
How to do you this? I am beginner in C-language
for more shapes code visit :)
http://cppexamples.blogspot.com/p/c-shapes-code.html
#include
using namespace std;
class parallelogram {
private:
//member Atributes
public:
void display(int, int);
};
void parallelogram::display(int row, int col) {
for (int i = 0; i < row; i++)
{
for (int j = 0; j < col; j++) {
cout << "*";
}
cout << endl;
}
}
void main() {
parallelogram object;
object.display(5, 12);
}
for more visit and join site
www.cppexamples.blogspot.com
If n = 4 the following output
1111
222
33
4
i need a programing for it
how about
helloworld
helloworl
hellowor
hellowo
hellow
hello
hell
hel
he
h
thanks.
Please..help me with this progam.im a beginner in c
Write a program to generate the given pattern.
CCCCC
S***S
S***S
S***S
KKKKK
#include
int main()
{
int i,j,k;
char name[40];
printf("Enter the word");
gets(name);
k=strlen(name);
for(i=0;i<k;i++)
{
for(j=0;j<k-i;j++)
{
printf("%c",name[j]);
}
printf("\n");
}
return 0;
}
How to make heart shape
How to make heart shape
how can i create cube "plz give me code"
how to print this pattern
1
2 3
or how to print
1
2 3 2
3 4 5 4 3
(upto n)
plz give me ans for this pattern
AAAA AA
A A A
A A A
A A A
AAA A A
A A A
A A A
AAA AA
i WANT TO PRINT THIS STRING "ERIC" IN FOLLOWING PATTERN
C
I C
R I C
E R I C
Post a Comment