locked
I Challange all the viwer to solve this C-Question RRS feed

  • Question



  • RULE:-
    Make a c Program in less than 10 line ,
    without using any pre-define function in C( u can use scanf and printf );


    Question: WAP that give no of character and no of words in a line..(max no. of line 9)

    Tuesday, September 18, 2007 7:57 PM

Answers

  • So Good............................

     

    But can u make this program without using any type of loops, conditional operator...........

     

    If u do then I am ur FAN DUDE

    Wednesday, September 19, 2007 9:41 AM

All replies

  • Heres the code Vivek,

     

    Code Snippet

     

    #include <stdio.h>
    main()
    {
     char str[] = "This is a test String";
     int charCount = printf("\n%s\n",str), blanks=0,i;
     for(i=0;i<charCount;i++)
      if (str[i] == ' ') blanks++;
     printf("\nCharacters=%d , Words = %d",charCount-blanks, blanks+1);
    }

     

     

     

    The code is in 9 lines, i.e less than 10 lines. Also i am printing the number of actual characters, ie characters without the blank.

    If i want to calculate the total characters including blank spaces, i just have to print charCount.

     

    So, do i get a prize???

     

    Tuesday, September 18, 2007 10:49 PM
  • So Good............................

     

    But can u make this program without using any type of loops, conditional operator...........

     

    If u do then I am ur FAN DUDE

    Wednesday, September 19, 2007 9:41 AM

  • gr8.......awesome.......
    Monday, September 24, 2007 11:04 AM
  • I think vivek u want a program that is composed of only white spaces and does what ever u think of.....

    Thursday, September 27, 2007 12:44 PM
  • THIS WAS REALLY GOOD CONTINUE TELLING THIS TYPE OF GOOD INFORMATIONS......

     

    Thursday, September 27, 2007 7:57 PM
  • Guys why is this specific problem important and what is the significance of 10 here....?
    Tuesday, October 2, 2007 6:24 AM