Results 1 to 4 of 4

Thread: Mujhy c++ seekni hai aik program bana k dikao

  1. #1
    fawadahmad's Avatar
    fawadahmad is offline Senior Member+
    Last Online
    25th August 2016 @ 06:20 PM
    Join Date
    28 Feb 2015
    Gender
    Male
    Posts
    177
    Threads
    19
    Credits
    0
    Thanked
    3

    Default Mujhy c++ seekni hai aik program bana k dikao

    Mujhy aik aysi program banao jis mai hum aik line dy jis mai humain ye us line mai mojood words gin k bataye.masllan "hum pakistani hai"
    Is mai 3words hai.anyone

  2. #2
    AsifSattarvi's Avatar
    AsifSattarvi is offline Advance Member
    Last Online
    12th October 2022 @ 02:54 PM
    Join Date
    20 May 2012
    Gender
    Male
    Posts
    6,594
    Threads
    104
    Credits
    30,058
    Thanked
    960

    Default

    اس کو چیک کریں
    ----------
    #include <stdio.h>

    int main (void) {

    char *line = NULL; /* pointer to use with getline () */
    char *p = NULL; /* pointer to parse getline return */
    ssize_t read = 0;
    size_t n = 0;
    int spaces = 0; /* counter for spaces and newlines */
    int total = 0; /* counter for total words read */

    printf ("\nEnter a line of text (or ctrl+d to quit)\n\n");

    while (printf (" input: ") && (read = getline (&line, &n, stdin)) != -1) {

    spaces = 0;
    p = line;

    if (read > 1) { /* read = 1 covers '\n' case (blank line with [enter]) */
    while (*p) { /* for each character in line */
    if (*p == '\t' || *p == ' ') { /* if space, */
    while (*p == '\t' || *p == ' ') /* read all spaces */
    p++;
    spaces += 1; /* consider sequence of spaces 1 */
    } else
    p++; /* if not space, increment pointer */
    }
    }

    total += spaces + 1; /* words in line = spaces + 1 */
    printf (" chars read: %2zd, spaces: %2d total: %3d line: %s\n",
    read, spaces, total, (read > 1) ? line : "[enter]\n");
    }

    printf ("\n\n Total words read: %d\n\n", total);

    return 0;

    }

  3. #3
    AsifSattarvi's Avatar
    AsifSattarvi is offline Advance Member
    Last Online
    12th October 2022 @ 02:54 PM
    Join Date
    20 May 2012
    Gender
    Male
    Posts
    6,594
    Threads
    104
    Credits
    30,058
    Thanked
    960

    Default

    یہ شاٹ طریقہ ہے
    #include <stdio.h>
    #include <conio.h>
    void main(){
    char s[50],ch;
    int i,c=0;
    clrscr();
    printf("Enter any string : ");
    for(i=0;ch!='\n';i++){
    ch=getchar();
    s[i]=ch;
    }
    s[i]='\0';

    for(i=0;s[i]!='\0';i++){
    if(s[i]==' '){
    c++;
    while(s[i]==' ')
    i++;
    }
    }
    printf("\n\nTotal words are %d",c+1);
    getch();
    }

  4. #4
    Haseeb Alamgir's Avatar
    Haseeb Alamgir is offline Super Moderator
    Last Online
    Yesterday @ 08:57 PM
    Join Date
    09 Apr 2009
    Location
    KARACHI&
    Gender
    Male
    Posts
    19,273
    Threads
    411
    Credits
    39,647
    Thanked
    1813

    Default

    لگتا ہے کہ ممبر کا مسلہ حل ہو گیا ہے اسی لئے ریپلائی نہیں کیا ابھی تک اس نے

Similar Threads

  1. Replies: 86
    Last Post: 15th September 2017, 12:31 PM
  2. Apni Pic Ko Apna Hi Icon Bana Lein Kissi Bhi Program Ka
    By Member1 in forum General Discussion
    Replies: 13
    Last Post: 18th March 2016, 08:28 AM
  3. Kia koi mujhy stamp bana de ga?
    By *Noor-ul-Ain* in forum Ask an Expert
    Replies: 22
    Last Post: 1st August 2013, 11:05 AM
  4. Prime numbers ka program bana dain plzzzzzzzzzz
    By planket in forum Ask an Expert
    Replies: 0
    Last Post: 16th January 2011, 11:54 AM
  5. mujhy teri mohabbat ne bohat buzdil bana dala...!!!!!
    By sunnyshah_6 in forum Design Poetry
    Replies: 22
    Last Post: 5th June 2010, 04:53 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •