none
C,C++ Tricky questions RRS feed

  • Question

  • Hi all this thread is for asking and ansering all c or c++ questons that you have let see who have some really nice questions.

    Its not neccessary u shld know answer if u have question just post question u wll et the anser.

     

     

    First question:-

    1) Write a c or c++ program to print "Heloo World" but without usind semicolon(Wink even once in code ??????

     

    I will be waiting for ansers.I will give anser in 1 day let see who can answer.

    Monday, October 1, 2007 9:33 PM

Answers

  • #include<stdio.h>

    void main()
    {
    if(printf("Hello World")) { }
    }
    Tuesday, October 2, 2007 4:01 AM
  •  

    Sry guyz actually i m in college hostel and internet wasn't working here Sad.

     

    So here is the answer-

     

    void main()
    {

    int a,b;

    cout<<"Ennter two numbers: ";
    cin>>a>>b;
    char cAngel,dBeer;

    strcat(c,d);

    cout<<Result= "<<strlen(c);
    }

    Monday, October 8, 2007 10:27 AM
  • Here's the answer ---

     

     

    Code Block

    #include<iostream.h>
    #include<stdlib.h>

     

    void (*func[2])(int);

     

    void main(int n=1)
    {

    int i;

     

    cout<<endl<<n;

     

    func[0]=&exit;
    func[1]=&main;

     

    i = ++n <= 10;

    (func[i])(n);

    }

     

     

    This code prints numbers from 1 through 10.

    Replace 10 with any positive number, and it would print the desired result.

    Sunday, October 14, 2007 10:06 AM
  • this code worked for me..

     

     

    Code Block

    node * reverse (node *x)

    {

    node *temp;

     

    if ( !(x && x -> next))

    return x;


    temp = reverse(x -> next);

     

    x -> next -> next = x;
    x -> next = NULL;

     

    return temp;

    }

     

     

     

    *temp is a temporary node.

    I've specified the required code only.

    I've not specified the declaration of the list.

    I hope that is understood.

    Friday, October 19, 2007 6:01 PM
  •  

    Here's an answer for the calendar program ---

    Just try it out. Its really good.

     

    And Chetan, wait dude, i'll post for your question too..

     

     

    Code Block

    #include<stdio.h>
    #include<conio.h>
    #include<dos.h>

     

    int skip=0,j;
    int calc(int moon,int yr);

    void frame(int month,int year);
    void line(int x,int y,int l,int t);
    void box(int x,int y,int x1,int y1);
    void vline(int x1,int y1,int x2,int y2);

    void box(int x,int y,int x1,int y1)
    {
     int i;
     for(i=1;i<x1-x;i++)
     {
      gotoxy(x+i,y);
      cprintf("Í");
      gotoxy(x+i,y1);
      cprintf("Í");
     }
     for(i=1;i<y1-y;i++)
     {
      gotoxy(x,y+i);
      cprintf("º");
      gotoxy(x1,y+i);
      cprintf("º");
     }
     gotoxy(x,y);cprintf("É");
     gotoxy(x1,y1);cprintf("¼");
     gotoxy(x1,y);cprintf("»");
     gotoxy(x,y1);cprintf("È");
    }

    void line(int x,int y,int l,int t)
    {
     int i;
     if(t==1)
     {
      gotoxy(x,y);cprintf("Ë");
      for(i=1; i<l; i++)
      {
       gotoxy(x,y+i);
       cprintf("º");
      }
      gotoxy(x,y+l);cprintf("Ê");
     }
     else
     {
      gotoxy(x,y);cprintf("Ì");
      for(i=1;i<l;i++)
      {
       gotoxy(x+i,y);
       cprintf("Í");

      }
      gotoxy(x+l,y);cprintf("¹");
     }
     gotoxy(10,10);
    }

    void vline(int x1,int y1,int x2,int y2)
    {
     int i;
     gotoxy(x1,y1-1);
     printf("Ë");
     for(i=y1; i<=y2; i++)
     {
      gotoxy(x1,i);
      printf("º");
     }
     gotoxy(x2,y2);        //  º Ë Ê
     printf("Ê");
    }

    void  frame(int year,int mon)
    {
     char month[12][10]=
     {
      "January","February","March","April","May","June",
      "July","August","September","October","November","December"
     };
     box(7,5,70,21);
     line(7,8,63,8);line(7,11,63,11); line(7,19,63,19); line(7,17,63,17);line(7,15,63,15);line(7,13,63,13);
     textbackground(BLACK);
     textbackground(GREEN);gotoxy(8,6);cprintf("                                                              ");
     textbackground(GREEN);gotoxy(8,7);cprintf("                                                              ");
     textbackground(GREEN);gotoxy(9,6);printf("MONTH :  ");
     textbackground(BLUE);gotoxy(28,6);cprintf(" * C A L E N D E R * ");
     gotoxy(17,6);puts(month[mon-1]);
     gotoxy(57,6);printf("YEAR :  %d",year);
     gotoxy(8,9); cprintf("%8s","SUN");
     gotoxy(17,9); cprintf("%8s","MON");
     gotoxy(26,9); cprintf("%8s","TUE");
     gotoxy(35,9); cprintf("%8s","WED");
     gotoxy(44,9); cprintf("%8s","THU");
     gotoxy(53,9); cprintf("%8s","FRI");
     gotoxy(62,9); cprintf("%8s","SAT");
     textbackground(RED); textcolor(BLACK|BLINK);gotoxy(14,23);cprintf(" %c Year %c ",24,25);textcolor(YELLOW);
     textbackground(RED); textcolor(BLACK|BLINK);gotoxy(55,23);cprintf(" %c Month %c ",27,26);textcolor(YELLOW);
     textbackground(RED); textcolor(BLACK|BLINK);gotoxy(33,23);cprintf(" Esc To Exit ",24,25);textcolor(YELLOW);
     vline(16,9,16,21); vline(25,9,25,21); vline(34,9,34,21); vline(43,9,43,21); vline(52,9,52,21); vline(61,9,61,21);
     textbackground(BLACK);
    }

    int calc(int moon,int yr)
    {
     int i;
     int a1=0,a2=31,a3=28,a4=31,a5=30,a6=31,a7=30,a8=31,a9=31,a10=30,a11=31,a12=30,a13;
     if(yr%4==0)
      a3=29;
     skip=0;
     for(i=1900; i<yr ; i++)
     {
      if(i%4==0)
       skip=skip+2;
      else
       skip=skip+1;
     }
     while(skip>=7)
      skip=skip-7;
     a1=skip;
     if(moon==1)
      return(a1);
     if(moon==2)
     {
      skip=a1+a2;                //
      while(skip>=7)
       skip=skip-7;
      a3=skip;
      return(a3);
     }
     if(moon==3)
     {
      skip=a1+a2+a3;             // for feburary
      while(skip>=7)
       skip=skip-7;
      a4=skip;
      return(a4);
     }
     if(moon==4)
     {
      skip=a1+a2+a3+a4;         //  for march
      while(skip>=7)
       skip=skip-7;
      a5=skip;
      return(a5);
     }
     if(moon==5)
     {
      skip=a5+a1+a2+a3+a4;     //  for  apr
      while(skip>=7)
       skip=skip-7;
      a6=skip;
      return(a6);
     }
     if(moon==6)
     {
      skip=a6+a1+a2+a3+a4+a5;     // for may
      while(skip>=7)
       skip=skip-7;
      a7=skip;
      return(a7);
     }
     if(moon==7)
     {
      skip=a1+a2+a3+a4+a5+a6+a7;    //  for jun
      while(skip>=7)
       skip=skip-7;
      a8=skip;
      return(a8);
     }
     if(moon==8)
     {
      skip=a1+a2+a3+a4+a5+a6+a7+a8;    // for jul
      while(skip>=7)
       skip=skip-7;
      a9=skip;
      return(a9);
     }
     if(moon==9)
     {
      skip=a1+a2+a3+a4+a5+a6+a7+a8+a9;   //  for  aug
      while(skip>=7)
       skip=skip-7;
      a10=skip ;
      return(a10);
     }
     if(moon==10)
     {
      skip=a1+a2+a3+a4+a5+a6+a7+a8+a9+a10;    //  for sept
      while(skip>=7)
       skip=skip-7;
      a11=skip;
      return(a11);
     }
     if(moon==11)
     {
      skip=a1+a2+a3+a4+a5+a6+a7+a8+a9+a10+a11;     // for oct
      while(skip>=7)
       skip=skip-7;
      a12=skip;
      return(a12);
     }
     if(moon==12)
     {
      skip=a1+a2+a3+a4+a5+a6+a7+a8+a9+a10+a11+a12;
      while(skip>=7)
       skip=skip-7;                               //  for nov
      a13=skip;
      return(a13);
     }
     else
     {
      printf("\n\n\n\n\n\n\n\t\t Wrong Entry");
      return(0);
     }
    }

    void _Calendar()
    {
     int ye,mo;
     int a;
     int l,d;
     int r=0,c=0;
     int ch;
     struct date date;            //d.da_day,d.da_mon,d.da_year
     getdate(&date);
     ye=date.da_year;
     mo=date.da_mon;
     _setcursortype(_NOCURSOR);
     textcolor(YELLOW);
     clrscr();
     do
     {
      if(ch==72)
       ye++;
      if(ch==80)
       ye--;
      if(ch==77)
       mo++;
      if(ch==75)
       mo--;
      if(mo==13)
      {
       ye++;
       mo=1;
      }
      if(mo==0)
      {
       ye--;
       mo=12;
      }
      clrscr();
      textbackground(BLACK);
      frame(ye,mo);
      a=calc(mo,ye);
      r=12;c=12;l=1;
      for(j=0; j<a; j++)
       c=c+9;
      for(d=a+1; d<=40; d++)
      {
       if(r>20)
        r=12;
       gotoxy(c,r);cprintf("%d",l);
       c=c+9;l++;
       if(d%7==0)
       {
        c=12; r=r+2;
       }
       if(mo==9 && l==31)    break;
       if(mo==1 && l==32)    break;
       if(mo==2 && ye%4==0 && l==30)    break;
       if(mo==2 && ye%4!=0 && l==29)    break;
       if(mo==3 && l==32)    break;
       if(mo==4 && l==31)    break;
       if(mo==5 && l==32)    break;
       if(mo==6 && l==31)    break;
       if(mo==7 && l==32)    break;
       if(mo==8 && l==32)    break;
       if(mo==9 && l==31)    break;
       if(mo==10 && l==32)    break;
       if(mo==11 && l==31)    break;
       if(mo==12 && l==32)    break;
      }
      ch=getch();
     }while(ch!=27);
    }

    void main()
    {
     _Calendar();
    }

     

     

    Friday, October 26, 2007 5:49 PM
  • Here's the answer ---

     

    Code Block

    int** func1(int **arg1)
    {
     int **temp,i,j;

     temp = new int*[3];
     for(i=0;i<3;i++)
      temp[i] = new int[3];

     cout<<endl<<"Displaying <temp>... values copied to <temp> and incremented by <5>"<<endl;

     for(i=0;i<3;i++)
     {
      for(j=0;j<3;j++)
      {
       temp[i][j] = arg1[i][j];   // COPY "arg1" to "temp"
       temp[i][j] += 5;           // INCREMENT each element of "temp" by "5"
       cout<<" "<<temp[i][j];     // DISPLAY "temp"
      }
      cout<<endl;
     }
     return temp;
    }

    void main()
    {
     clrscr();
     int **a;
     int i,j;
     a = new int*[3];
     for(i=0;i<3;i++)
      a[i] = new int[3];
     cout<<endl<<"Enter NINE values --- 3 by 3 matrix"<<endl;
     for(i=0;i<3;i++)
     {
      for(j=0;j<3;j++)
      {
       cin>>a[i][j];
      }
      cout<<endl;
     }

     cout<<endl<<"Displaying <a> before operation..."<<endl;

     for(i=0;i<3;i++)
     {
      for(j=0;j<3;j++)
      {
       cout<<" "<<a[i][j];
      }
      cout<<endl;
     }

     

     a=func1(a);

     

     cout<<endl<<"Displaying <a> after operation... result stored in <a>"<<endl;

     for(i=0;i<3;i++)
     {
      for(j=0;j<3;j++)
      {
       cout<<" "<<a[i][j];
      }
      cout<<endl;
     }

     delete a;         // free <a>
    }

     

     

    Monday, November 5, 2007 6:40 PM
  •  PRAVEEN_KUMAR_cb73f6 wrote:

    how 2 put integer value or any number into array....using c program.

    eg...
    input i = 123

    output
    a[0]=1
    a[1]=2
    a[2]=3


     

    dude u can do it using atoi function sry i don't have c or c++ here in my net lab so will give u answer in 2 days plz but try atoi fuction i think it will solve ur problem.

     

    i will give u whole program this weekend sry for delayed answers Sad

    Monday, November 19, 2007 9:43 AM
  •  PRAVEEN_KUMAR_cb73f6 wrote:

    how 2 put integer value or any number into array....using c program.

    eg...
    input i = 123

    output
    a[0]=1
    a[1]=2
    a[2]=3




    Hey dude sry to be late here is ur code :-

    #include <stdlib.h>
    #include <stdio.h>

    int main(void)
    {
       int n;
       char *str = "12345";

       n = atoi(str);
       printf("string = %s integer = %d\n", str, n);
       return 0;
    }

    Friday, November 30, 2007 6:50 PM
  •  PRAVEEN_KUMAR_cb73f6 wrote:

    how 2 put integer value or any number into array....using c program.

    eg...
    input i = 123

    output
    a[0]=1
    a[1]=2
    a[2]=3




    Hey dude sry to be late here is ur code :-

    #include <stdlib.h>
    #include <stdio.h>

    int main(void)
    {
       int n;
       char *str = "12345";

       n = atoi(str);
       printf("string = %s integer = %d\n", str, n);
       return 0;
    }

    Friday, November 30, 2007 6:52 PM
  • Predict the output of the following :

     

    Code Block

    #include<iostream.h>

    void main()

    {int a=10,b;

     b=(a++,a++,a++);

     cout<<a<<" "<<b;

    }

     

     

     

    Sunday, December 16, 2007 3:09 PM

All replies

  • #include<stdio.h>

    void main()
    {
    if(printf("Hello World")) { }
    }
    Tuesday, October 2, 2007 4:01 AM
  •  

    hey very nice
    Tuesday, October 2, 2007 6:26 AM
  •  Jayakumar_Jayaprakasan_9a8c86 wrote:
    #include<stdio.h>

    void main()
    {
    if(printf("Hello World")) { }
    }

     

    Nice answer dude

    Wednesday, October 3, 2007 3:55 AM
  • Next Question:-

     

    How can you add Two number without using any operator ?

     

    (either in c or c++)

    I will provide the answer after 1 day.

     

    • Proposed as answer by rohilla Monday, July 19, 2010 11:04 AM
    Wednesday, October 3, 2007 4:47 AM
  • jaggi i think u r little slow

    Thursday, October 4, 2007 9:25 AM
  • Hey whers d reply dude

    Friday, October 5, 2007 8:49 AM
  • go to site esnips.com

     

    Saturday, October 6, 2007 12:36 PM
  • sorry dont know.

     

     

    Saturday, October 6, 2007 12:38 PM
  • how this is works

     

     

    Saturday, October 6, 2007 12:38 PM
  • i like u very much

     

    Saturday, October 6, 2007 12:41 PM
  • I think no way for if. Because when we try even with multiple compliment addition of binary we have to use binary oparator

    Monday, October 8, 2007 6:45 AM
  •  

    Sry guyz actually i m in college hostel and internet wasn't working here Sad.

     

    So here is the answer-

     

    void main()
    {

    int a,b;

    cout<<"Ennter two numbers: ";
    cin>>a>>b;
    char cAngel,dBeer;

    strcat(c,d);

    cout<<Result= "<<strlen(c);
    }

    Monday, October 8, 2007 10:27 AM
  • Write a C++ program without using any loop (if, for, while etc) to print numbers.

    I will give answer on monday in 2 days.
    Saturday, October 13, 2007 2:06 PM
  •  Chetan Jaggi wrote:

     

    Sry guyz actually i m in college hostel and internet wasn't working here .

     

    So here is the answer-

     

    void main()
    {

    int a,b;

    cout<<"Ennter two numbers: ";
    cin>>a>>b;
    char c,d;

    strcat(c,d);

    cout<<Result= "<<strlen(c);
    }

     

    Hello dude put the code in code snippet... I couldn't understand the line  " char c xx, d xx;"

    Sunday, October 14, 2007 5:19 AM
  •  Chetan Jaggi wrote:
    Write a C++ program without using any loop (if, for, while etc) to print numbers.

    I will give answer on monday in 2 days.

     

    Do you mean numbers from 1 to n (say 100 ) ??

    Sunday, October 14, 2007 5:21 AM
  • Here's the answer ---

     

     

    Code Block

    #include<iostream.h>
    #include<stdlib.h>

     

    void (*func[2])(int);

     

    void main(int n=1)
    {

    int i;

     

    cout<<endl<<n;

     

    func[0]=&exit;
    func[1]=&main;

     

    i = ++n <= 10;

    (func[i])(n);

    }

     

     

    This code prints numbers from 1 through 10.

    Replace 10 with any positive number, and it would print the desired result.

    Sunday, October 14, 2007 10:06 AM
  • Hey! post more questions.. I'm waiting to answer.

     

    Monday, October 15, 2007 5:46 PM
  • e
     jain.nishit wrote:
    Hey! post more questions.. I'm waiting to answer.

     



    Here is what u want Next Question Smile

    Reverse a singly linked list recursively. The function prototype is node * reverse (node *) .

    Hey guyz u can also post ur questions.So plz u also plz post some questions but plz one question at a time.
    Thursday, October 18, 2007 9:04 PM
  • this code worked for me..

     

     

    Code Block

    node * reverse (node *x)

    {

    node *temp;

     

    if ( !(x && x -> next))

    return x;


    temp = reverse(x -> next);

     

    x -> next -> next = x;
    x -> next = NULL;

     

    return temp;

    }

     

     

     

    *temp is a temporary node.

    I've specified the required code only.

    I've not specified the declaration of the list.

    I hope that is understood.

    Friday, October 19, 2007 6:01 PM
  • Nice answer only u giving all answers Smile.

    U can also ask ur questions this thread is open for all.
    And if you find my questions useful plz mark it

    I will post next question tonight if no one else posts.
    Saturday, October 20, 2007 10:18 AM
  • Thanx man!

     

    Yes i'll be posting some questions in a few days from now. Just wait for some time.

    Post your questions in the mean time.

     

    And OTHERS can also post their questions.

    We'll definitely try to solve them.

    Saturday, October 20, 2007 1:08 PM
  •  

    A new challenge

     

    Display the non Fibonacci series

     

    Ex- 4 6 7 9 10 11 12 ..........................

    Sunday, October 21, 2007 9:17 AM
  • One way can be to print all numbers and keep checking for a number that it is in fibonacci series or not.

     

    Any other idea so plz tell me i am in hostel i will also try some other if i get a pc.Smile

     

    Till then here is next question:-

    ////////////////////////////////////////////////////////////////////////

     

    Provide c++ code to complete this program Smile

     

     

    int** func1(int** arg1)

    {

    int** temp;

    //allocate memory dynamically then copy arg1 to temp increment every element in temp by 5

    // then print temp

     

    //return temp

    }

     

    void main()

    {

    int** a;

    // allocate memory dynamically then assign a 3x3 matrix in a

    //print a

     

    // call a and save result returned in a only then print a

     

    //output of last two print statements should be same

     

     

    //free the space of a

     

    }

    //////////////////////////////////////////

    Monday, October 22, 2007 8:58 AM
  • Common guyz i am waiting for replies

     

    Thursday, October 25, 2007 3:57 AM

  •      Write a program to print the calendar, which is constraint to only 5 rows
    as :
      January 2000
    Sun     Mon    Tue   Wed    Thu    Fri    Sat
    30       31                                 1
    2         3      4     5      6      7      8
    9        10     11    12     13     14     15
    16       17     18    19     20     21     22
    23       24     25    26     27     28     29


    Thursday, October 25, 2007 5:42 AM
  •  PRAVEEN_KUMAR_cb73f6 wrote:

         Write a program to print the calendar, which is constraint to only 5 rows
    as :
      January 2000
    Sun     Mon    Tue   Wed    Thu    Fri    Sat
    30       31                                 1
    2         3      4     5      6      7      8
    9        10     11    12     13     14     15
    16       17     18    19     20     21     22
    23       24     25    26     27     28     29




    Bro sry for interuption but plzz one question at a time plzzzzz.
    Thursday, October 25, 2007 6:32 PM
  •  

    Here's an answer for the calendar program ---

    Just try it out. Its really good.

     

    And Chetan, wait dude, i'll post for your question too..

     

     

    Code Block

    #include<stdio.h>
    #include<conio.h>
    #include<dos.h>

     

    int skip=0,j;
    int calc(int moon,int yr);

    void frame(int month,int year);
    void line(int x,int y,int l,int t);
    void box(int x,int y,int x1,int y1);
    void vline(int x1,int y1,int x2,int y2);

    void box(int x,int y,int x1,int y1)
    {
     int i;
     for(i=1;i<x1-x;i++)
     {
      gotoxy(x+i,y);
      cprintf("Í");
      gotoxy(x+i,y1);
      cprintf("Í");
     }
     for(i=1;i<y1-y;i++)
     {
      gotoxy(x,y+i);
      cprintf("º");
      gotoxy(x1,y+i);
      cprintf("º");
     }
     gotoxy(x,y);cprintf("É");
     gotoxy(x1,y1);cprintf("¼");
     gotoxy(x1,y);cprintf("»");
     gotoxy(x,y1);cprintf("È");
    }

    void line(int x,int y,int l,int t)
    {
     int i;
     if(t==1)
     {
      gotoxy(x,y);cprintf("Ë");
      for(i=1; i<l; i++)
      {
       gotoxy(x,y+i);
       cprintf("º");
      }
      gotoxy(x,y+l);cprintf("Ê");
     }
     else
     {
      gotoxy(x,y);cprintf("Ì");
      for(i=1;i<l;i++)
      {
       gotoxy(x+i,y);
       cprintf("Í");

      }
      gotoxy(x+l,y);cprintf("¹");
     }
     gotoxy(10,10);
    }

    void vline(int x1,int y1,int x2,int y2)
    {
     int i;
     gotoxy(x1,y1-1);
     printf("Ë");
     for(i=y1; i<=y2; i++)
     {
      gotoxy(x1,i);
      printf("º");
     }
     gotoxy(x2,y2);        //  º Ë Ê
     printf("Ê");
    }

    void  frame(int year,int mon)
    {
     char month[12][10]=
     {
      "January","February","March","April","May","June",
      "July","August","September","October","November","December"
     };
     box(7,5,70,21);
     line(7,8,63,8);line(7,11,63,11); line(7,19,63,19); line(7,17,63,17);line(7,15,63,15);line(7,13,63,13);
     textbackground(BLACK);
     textbackground(GREEN);gotoxy(8,6);cprintf("                                                              ");
     textbackground(GREEN);gotoxy(8,7);cprintf("                                                              ");
     textbackground(GREEN);gotoxy(9,6);printf("MONTH :  ");
     textbackground(BLUE);gotoxy(28,6);cprintf(" * C A L E N D E R * ");
     gotoxy(17,6);puts(month[mon-1]);
     gotoxy(57,6);printf("YEAR :  %d",year);
     gotoxy(8,9); cprintf("%8s","SUN");
     gotoxy(17,9); cprintf("%8s","MON");
     gotoxy(26,9); cprintf("%8s","TUE");
     gotoxy(35,9); cprintf("%8s","WED");
     gotoxy(44,9); cprintf("%8s","THU");
     gotoxy(53,9); cprintf("%8s","FRI");
     gotoxy(62,9); cprintf("%8s","SAT");
     textbackground(RED); textcolor(BLACK|BLINK);gotoxy(14,23);cprintf(" %c Year %c ",24,25);textcolor(YELLOW);
     textbackground(RED); textcolor(BLACK|BLINK);gotoxy(55,23);cprintf(" %c Month %c ",27,26);textcolor(YELLOW);
     textbackground(RED); textcolor(BLACK|BLINK);gotoxy(33,23);cprintf(" Esc To Exit ",24,25);textcolor(YELLOW);
     vline(16,9,16,21); vline(25,9,25,21); vline(34,9,34,21); vline(43,9,43,21); vline(52,9,52,21); vline(61,9,61,21);
     textbackground(BLACK);
    }

    int calc(int moon,int yr)
    {
     int i;
     int a1=0,a2=31,a3=28,a4=31,a5=30,a6=31,a7=30,a8=31,a9=31,a10=30,a11=31,a12=30,a13;
     if(yr%4==0)
      a3=29;
     skip=0;
     for(i=1900; i<yr ; i++)
     {
      if(i%4==0)
       skip=skip+2;
      else
       skip=skip+1;
     }
     while(skip>=7)
      skip=skip-7;
     a1=skip;
     if(moon==1)
      return(a1);
     if(moon==2)
     {
      skip=a1+a2;                //
      while(skip>=7)
       skip=skip-7;
      a3=skip;
      return(a3);
     }
     if(moon==3)
     {
      skip=a1+a2+a3;             // for feburary
      while(skip>=7)
       skip=skip-7;
      a4=skip;
      return(a4);
     }
     if(moon==4)
     {
      skip=a1+a2+a3+a4;         //  for march
      while(skip>=7)
       skip=skip-7;
      a5=skip;
      return(a5);
     }
     if(moon==5)
     {
      skip=a5+a1+a2+a3+a4;     //  for  apr
      while(skip>=7)
       skip=skip-7;
      a6=skip;
      return(a6);
     }
     if(moon==6)
     {
      skip=a6+a1+a2+a3+a4+a5;     // for may
      while(skip>=7)
       skip=skip-7;
      a7=skip;
      return(a7);
     }
     if(moon==7)
     {
      skip=a1+a2+a3+a4+a5+a6+a7;    //  for jun
      while(skip>=7)
       skip=skip-7;
      a8=skip;
      return(a8);
     }
     if(moon==8)
     {
      skip=a1+a2+a3+a4+a5+a6+a7+a8;    // for jul
      while(skip>=7)
       skip=skip-7;
      a9=skip;
      return(a9);
     }
     if(moon==9)
     {
      skip=a1+a2+a3+a4+a5+a6+a7+a8+a9;   //  for  aug
      while(skip>=7)
       skip=skip-7;
      a10=skip ;
      return(a10);
     }
     if(moon==10)
     {
      skip=a1+a2+a3+a4+a5+a6+a7+a8+a9+a10;    //  for sept
      while(skip>=7)
       skip=skip-7;
      a11=skip;
      return(a11);
     }
     if(moon==11)
     {
      skip=a1+a2+a3+a4+a5+a6+a7+a8+a9+a10+a11;     // for oct
      while(skip>=7)
       skip=skip-7;
      a12=skip;
      return(a12);
     }
     if(moon==12)
     {
      skip=a1+a2+a3+a4+a5+a6+a7+a8+a9+a10+a11+a12;
      while(skip>=7)
       skip=skip-7;                               //  for nov
      a13=skip;
      return(a13);
     }
     else
     {
      printf("\n\n\n\n\n\n\n\t\t Wrong Entry");
      return(0);
     }
    }

    void _Calendar()
    {
     int ye,mo;
     int a;
     int l,d;
     int r=0,c=0;
     int ch;
     struct date date;            //d.da_day,d.da_mon,d.da_year
     getdate(&date);
     ye=date.da_year;
     mo=date.da_mon;
     _setcursortype(_NOCURSOR);
     textcolor(YELLOW);
     clrscr();
     do
     {
      if(ch==72)
       ye++;
      if(ch==80)
       ye--;
      if(ch==77)
       mo++;
      if(ch==75)
       mo--;
      if(mo==13)
      {
       ye++;
       mo=1;
      }
      if(mo==0)
      {
       ye--;
       mo=12;
      }
      clrscr();
      textbackground(BLACK);
      frame(ye,mo);
      a=calc(mo,ye);
      r=12;c=12;l=1;
      for(j=0; j<a; j++)
       c=c+9;
      for(d=a+1; d<=40; d++)
      {
       if(r>20)
        r=12;
       gotoxy(c,r);cprintf("%d",l);
       c=c+9;l++;
       if(d%7==0)
       {
        c=12; r=r+2;
       }
       if(mo==9 && l==31)    break;
       if(mo==1 && l==32)    break;
       if(mo==2 && ye%4==0 && l==30)    break;
       if(mo==2 && ye%4!=0 && l==29)    break;
       if(mo==3 && l==32)    break;
       if(mo==4 && l==31)    break;
       if(mo==5 && l==32)    break;
       if(mo==6 && l==31)    break;
       if(mo==7 && l==32)    break;
       if(mo==8 && l==32)    break;
       if(mo==9 && l==31)    break;
       if(mo==10 && l==32)    break;
       if(mo==11 && l==31)    break;
       if(mo==12 && l==32)    break;
      }
      ch=getch();
     }while(ch!=27);
    }

    void main()
    {
     _Calendar();
    }

     

     

    Friday, October 26, 2007 5:49 PM

  • @jain

    let me checkout...but u did so quick....
    Saturday, October 27, 2007 8:23 AM
  • ya he is so quick.
    I was also working on this qestion but its a long program and due to lack of PCin hostel couldn't coplete it Sad


    And i will be waiting for your answer jain .
    Sunday, October 28, 2007 7:18 AM
  •  

     

    Tuesday, October 30, 2007 6:17 AM
  • still waiting for ur answer
    Thursday, November 1, 2007 10:57 AM
  • very very good

    Friday, November 2, 2007 7:12 AM
  • Common guyz can no one answer this question ??

    Till then here is next question:-

    ////////////////////////////////////////////////////////////////////////

     

    Provide c++ code to complete this program

     

     

    int** func1(int** arg1)

    {

    int** temp;

    //allocate memory dynamically then copy arg1 to temp increment every element in temp by 5

    // then print temp

     

    //return temp

    }

     

    void main()

    {

    int** a;

    // allocate memory dynamically then assign a 3x3 matrix in a

    //print a

     

    // call a and save result returned in a only then print a

     

    //output of last two print statements should be same

     

     

    //free the space of a

     

    }

    //////////////////////////////////////////





    if u can't reply i will post anser in nxt 48 hrs if ono one can answer.This was such a basic question.


    Monday, November 5, 2007 4:50 PM
  • Here's the answer ---

     

    Code Block

    int** func1(int **arg1)
    {
     int **temp,i,j;

     temp = new int*[3];
     for(i=0;i<3;i++)
      temp[i] = new int[3];

     cout<<endl<<"Displaying <temp>... values copied to <temp> and incremented by <5>"<<endl;

     for(i=0;i<3;i++)
     {
      for(j=0;j<3;j++)
      {
       temp[i][j] = arg1[i][j];   // COPY "arg1" to "temp"
       temp[i][j] += 5;           // INCREMENT each element of "temp" by "5"
       cout<<" "<<temp[i][j];     // DISPLAY "temp"
      }
      cout<<endl;
     }
     return temp;
    }

    void main()
    {
     clrscr();
     int **a;
     int i,j;
     a = new int*[3];
     for(i=0;i<3;i++)
      a[i] = new int[3];
     cout<<endl<<"Enter NINE values --- 3 by 3 matrix"<<endl;
     for(i=0;i<3;i++)
     {
      for(j=0;j<3;j++)
      {
       cin>>a[i][j];
      }
      cout<<endl;
     }

     cout<<endl<<"Displaying <a> before operation..."<<endl;

     for(i=0;i<3;i++)
     {
      for(j=0;j<3;j++)
      {
       cout<<" "<<a[i][j];
      }
      cout<<endl;
     }

     

     a=func1(a);

     

     cout<<endl<<"Displaying <a> after operation... result stored in <a>"<<endl;

     for(i=0;i<3;i++)
     {
      for(j=0;j<3;j++)
      {
       cout<<" "<<a[i][j];
      }
      cout<<endl;
     }

     delete a;         // free <a>
    }

     

     

    Monday, November 5, 2007 6:40 PM
  • No more questions?

    I miss you jaggi..

    Tuesday, November 13, 2007 7:36 PM

  • how 2 put integer value or any number into array....using c program.

    eg...
    input i = 123

    output
    a[0]=1
    a[1]=2
    a[2]=3


    Wednesday, November 14, 2007 7:16 AM
  •  PRAVEEN_KUMAR_cb73f6 wrote:

    how 2 put integer value or any number into array....using c program.

    eg...
    input i = 123

    output
    a[0]=1
    a[1]=2
    a[2]=3




    got the answers...that time my mind was not working..

    Thursday, November 15, 2007 6:01 AM
  •  

    Hi jain i am also missing you Smile.

     

    Actaually i am in hostel and net facility here in my campus sux so didn't replied for long i will post new questions frm this weekend as internals are going on.

     

    Monday, November 19, 2007 9:41 AM
  •  PRAVEEN_KUMAR_cb73f6 wrote:

    how 2 put integer value or any number into array....using c program.

    eg...
    input i = 123

    output
    a[0]=1
    a[1]=2
    a[2]=3


     

    dude u can do it using atoi function sry i don't have c or c++ here in my net lab so will give u answer in 2 days plz but try atoi fuction i think it will solve ur problem.

     

    i will give u whole program this weekend sry for delayed answers Sad

    Monday, November 19, 2007 9:43 AM
  • Put flash lite on code plz...
    Friday, November 23, 2007 10:20 PM
  •  PRAVEEN_KUMAR_cb73f6 wrote:

    how 2 put integer value or any number into array....using c program.

    eg...
    input i = 123

    output
    a[0]=1
    a[1]=2
    a[2]=3




    Hey dude sry to be late here is ur code :-

    #include <stdlib.h>
    #include <stdio.h>

    int main(void)
    {
       int n;
       char *str = "12345";

       n = atoi(str);
       printf("string = %s integer = %d\n", str, n);
       return 0;
    }

    Friday, November 30, 2007 6:50 PM
  •  PRAVEEN_KUMAR_cb73f6 wrote:

    how 2 put integer value or any number into array....using c program.

    eg...
    input i = 123

    output
    a[0]=1
    a[1]=2
    a[2]=3




    Hey dude sry to be late here is ur code :-

    #include <stdlib.h>
    #include <stdio.h>

    int main(void)
    {
       int n;
       char *str = "12345";

       n = atoi(str);
       printf("string = %s integer = %d\n", str, n);
       return 0;
    }

    Friday, November 30, 2007 6:52 PM
  • Predict the output of the following :

     

    Code Block

    #include<iostream.h>

    void main()

    {int a=10,b;

     b=(a++,a++,a++);

     cout<<a<<" "<<b;

    }

     

     

     

    Sunday, December 16, 2007 3:09 PM
  • output will be 13 12
    Monday, December 17, 2007 7:07 AM

  • @ jaggi

    can u explain why..???
    Monday, December 17, 2007 3:12 PM

  • NO more ques ah??????????

    Saturday, January 5, 2008 6:02 AM


  • Really happy about this forum.. Today only i got to know about this forum:

    1. Write a pgm to delete a node from a single link list , without using starting node?
    2. Reverse bits of short int ?

    Regards,
    Tomz..



    Wednesday, April 23, 2008 11:44 AM
  • C/C++

    Sr. No. Title Resources
    1. C/C++ - Tutorials 15 Records
    2. C/C++ - Question Bank 3 Records
    3. C/C++ - Assignments 18 Records
    4. C/C++ - Source Codes 118 Records
    5. C/C++ - EBooks 29 Records
    6. C/C++ - Video Tutorials 14 Records



    Wednesday, May 7, 2008 9:45 AM
  • #include<iostream.h>

    #include<conio.h>

    {

       int l=0,number,a[12],m;

    //read number

       cout<<"\n\n\t\t\tenter number";

        cin>>number;

         m=number;

        

    //first we will find length of number

    while(m>0)

    {

          l++;

          m/=10;

    }

     

    m=number; 

    // now store digit into array

    for(int i=l;i>=0;i--)

    {

         aIdea=m%10;

         m/=10;

    }

    //now display array

    for(i=0;i<l;i++)

    cout<<"\t"<<aIdea;

    getch();

    }

    Tuesday, September 30, 2008 7:22 PM
  • nice posts
    keep it up!
    Wednesday, October 8, 2008 2:50 PM
  •  Chetan Jaggi wrote:
    output will be 13 12

     

    May I know why it is 13 12? Could you explain to me?

     

    Thanks in advance.

    Tuesday, October 14, 2008 5:40 AM
  • third a is assigned to b before increment
    Tuesday, October 14, 2008 11:06 PM
  • Here is another simple way. Dont pass any command line arguments.

    Replece the 10 with any number.

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

    #define MAX 10

    main(int argc,char *argv[])
    {
       if (argc == MAX+1)
      {
         getch();
         return 0;
      }
      printf("%d \n",argc);
      main(++argc,NULL);
    }

    Sunday, January 25, 2009 10:41 PM
  • #include<iostream>
    using namespace std;
    void main()
    {int a,b;
    cin>>a>>b;
    while(b--)
    {
    a++;
    }

    cout<<"sum of two numbers is"<<a;
    }
    Thursday, January 14, 2010 5:39 PM
  • I am building webside building services and I have  several errors  so how do i now which mistake  I am doing
    Friday, February 5, 2010 12:20 AM
  • #include<iostream.h>

    void main()

    {

    if(cout<<"hello world")

    {

    }

    }

    Monday, July 19, 2010 11:03 AM
  • void main()

    {

       if(printf("hello world"))

       {

       }

     

    } // end of main

    Tuesday, August 9, 2011 6:20 AM
  • if(printf("hello word"))
    Tuesday, October 11, 2011 2:36 PM
  • //program to Display the non Fibonacci series#include<iostream>
    #include<stdlib.h>
    using namespace std;

    int main()
    {
        int a,b,c;
        a=0;
        b=1;
        c=1;
        int j=0,n;
        cout << "How many non fibonacci terms u wanna print?";
        cin >> n;
        while( j<n)
        {
            for(int i=a+1;i<b;i++)
            {
                if(j==n)
                    return 0;
                cout << "\n" << i;
                j++;
            }
            a=b;
            b=c;
            c=a+b;
        }
        return 0;
    }
    • Proposed as answer by Shaikh Yasin Friday, October 5, 2012 7:14 PM
    Friday, October 5, 2012 6:53 PM
  • #include<stdio.h>

    #include<conio.h>

    #define  a  ;

    void main()

    {

      clrscr()a

      printf("\nHeloo World")a

      getch()a

    }

    Thursday, June 11, 2015 4:11 AM
  • IF(COUT<<"HELLO WORLD")

    {

    ....

    }

    Friday, March 3, 2017 12:44 PM