[ Ics 103 Computer Programming in C Discussion ]

الموضوع في 'علوم الحاسب الآلي' بواسطة newb, بتاريخ ‏5 فبراير 2012.

  1. [ عــمــر ]

    [ عــمــر ] [... وَاذكر ربّك إذا نسيت

    انضم:
    ‏14 مايو 2012
    المشاركات:
    1,725
    الصفحة الرئيسية:
    التقييمات:
    +16 / 0 / -1
    ^

    خطأين في الشفرة .

    1 - كنت تطبع في كل مرة " You did not typed A,a ... "
    حتى لو أنه فعلا أدخل إدخالاً صحيحاً ، والحل في عمل جملة شرطية
    تتأكد من ذلك قبل طباعة الجملة.

    2 - الشرط الذي تكرر به الكود به مشكلة .
    أنت قلت
    كود:
    while (c != 'A' || c != 'a')
    افرض أنّي أدخلت A .
    الجزء الثاني من الشرط في هذه الحالة تحقق ، وهو c != 'a' .
    فبالتالي سيعيد الدخول في الحلقة من جديد ليكرر الشفرة .

    والشرط الصحيح كما كتبته :
    **
    كود PHP:
    # include <stdio.h>


    int main(void)
    {
        
    char c;
        do  {
            
    printf("Enter A or a : ");
            
    scanf(" %c", &c);
            
            if ( 
    c!= 'a' && c!= 'A' )
            
    printf("Sorry you didn't type A or a, try again\n");
            
        }
        while (
    c!= 'a' && c!= 'A');
        
    printf("Letter typed is %c"c);
        
        
    //getch(0);
        
    return(0);
        
        
    }
    **اطلع على الشرط وافهمه جيداً .
     
  2. [ عــمــر ]

    [ عــمــر ] [... وَاذكر ربّك إذا نسيت

    انضم:
    ‏14 مايو 2012
    المشاركات:
    1,725
    الصفحة الرئيسية:
    التقييمات:
    +16 / 0 / -1
    وهناك طريقة أخرى أفضلها شخصيا،
    وهي أن تقوم بتحول القيمة بداخل c إلى small case letter .
    بعد ذلك تقوم بالتحقق من إدخال a فقط .
     
  3. عبادي2013

    انضم:
    ‏1 يونيو 2014
    المشاركات:
    115
    التقييمات:
    +10 / 0 / -1
    شباب عندي ذا الكود هو مطلوب اني استخدم nestef loop بس مني عارف كيف اسويها
    كود PHP:
       #include<stdio.h>
       
    int main(void) {
           
    int num ;
           do {
               
                   
    printf("enter any integer between 1 and 10 > ");
                 
    scanf("%d",&num);
           
           
                 if(
    num>&&num<10)
                
    printf("*");
           }  while (
    num>10 && num <1);
              
    printf("input should be between 1 and 10");
       
           
           return 
    ;

       }
      
     
  4. ambitious 91

    ambitious 91 عضو

    انضم:
    ‏11 يناير 2013
    المشاركات:
    212
    التقييمات:
    +3 / 0 / -1
    ممكن تحط السؤال عشان نعرف!؟ وشكرا :)
     
  5. عبادي2013

    انضم:
    ‏1 يونيو 2014
    المشاركات:
    115
    التقييمات:
    +10 / 0 / -1
    هذا السؤال
    Using nested for loops, write a C program to print the pattern shown in the sample runs below on the screen.

    Sample runs:

    والصورة نفس اللي حطيتها في الرد الاول
     
  6. عبادي2013

    انضم:
    ‏1 يونيو 2014
    المشاركات:
    115
    التقييمات:
    +10 / 0 / -1
    شباب ايش المشكلة في ذا الكود ؟؟

    كود PHP:
    #include<stdio.h>

    int main (void) {
        
        
    int num,x;
        
        
    printf("Enter any integer number to be displayed in reverse :");
        
    scanf ("%d",&num);
        
    printf("reverse value = %d",x);

        while(
    num!= 0) {
        
         
    num 10;
        
        
    num num 10 ;
        
         
    printf("%d",x);
        
         
        
        
        
         
        
        }


        
        return 
    0;
    }
     
  7. المنكسرلله

    انضم:
    ‏20 يونيو 2010
    المشاركات:
    2,289
    التخصص:
    COE
    الجامعة:
    KFUPM
    سنة التخرج:
    2014
    التقييمات:
    +190 / 0 / -60
    ^^
    شكله كويسـ
    مزعجني شوي سطر
    كود PHP:
     printf("reverse value = %d",x); 
    لكنه ليس ذا بال
    فايش اللي مزعجك فيه؟
     
  8. GAMOFRN

    GAMOFRN عضو

    انضم:
    ‏24 يونيو 2012
    المشاركات:
    879
    التخصص:
    Chemical Engineering
    الجامعة:
    KFUPM
    سنة التخرج:
    2018
    التقييمات:
    +181 / 0 / -3
    Write a function maxmin that receives 3 distinct real values and returns the maximum and the minimum.
    In the main function read 3 values. If they are distinct, call maxmin function and display the maximum and minimum; otherwise print an error message saying that the entered values are not distinct.


    شباب انا سويت البرنامج .. لكن ماعرف كيف اطلع ال max & min ..

    طبعا هذا الاب كان عن ال pointers .
     
  9. Boss1

    Boss1 عضو

    انضم:
    ‏4 ديسمبر 2013
    المشاركات:
    44
    التقييمات:
    +1 / 0 / -0
    شباب الي حل التاسكات التاليه
    ياريت يعطيني الكود حقها
    لاب 7 تاسك 1 :

    Using sentinel controlled loop (while or for loop), write a program that reads a radius from the user and displays the area and circumference of the circle with that radius. This task is repeated until the
    user types 0.Assume that the radius is in centimeters. Use a named constant PI with value 3.1429


    لاب 6 تاسك 2 :

    The value for pi can be determined by the series equation


    Write a program to approximate the value of pi using the formula given including terms up through 1/99.


    لاب 6 تاسك 3 :

    You would like to find the area under the curve
    y = f(x)
    between the lines x = a and x = b . One way to approximate this area is to use line segments as approximations of small pieces of the curve and then to sum the areas of trapezoids created by drawing perpendiculars from the line segment endpoints to the x -axis, as shown in the above figure . We will assume that f ( x ) is nonnegative over the interval [ a , b ]. The trapezoidal rule approximates this area T as

    T=h/2 (f(a)+f(b)+2∑_(i=1)^(n-1)▒〖f(x_i 〗))
    For n subintervals of length h:
    h=(b-a)/n
    The value of x_i is given by : x_i=a+ih

    Write a function trapezoid with input parameters a , b , and n to implement the trapezoidal rule. This function calls the function f returns its value based on the value of x. Below are 2 examples of function f that you need to define.
    As shown, the function trapezoid is called with values for n of 2, 4, 8, 16, 32, 64, and 128.
    Hint: Here you have 2 counting loops; one in the main to go over the values of divisions n and another in the function trapezoid to go over the values of I from 1 to n-1.
    Note: If you have studied calculus, you will observe that the trapezoidal rule is approximating ∫_a^b▒f(x)dx
    f(x)=x^3 exact area= (b4-a4)/4


    f(x)=sin⁡(x) exact area=cos(a)-cos(b)


    ضروري الله يعافيكممممم اليووووم
     
  10. zizo1212

    zizo1212 عضو

    انضم:
    ‏15 ابريل 2013
    المشاركات:
    86
    التقييمات:
    +0 / 0 / -0
    ياشباب، كم الباس عادة في المادة Ics103؟؟
     
  11. شدعوه

    شدعوه مشرف سابق

    انضم:
    ‏12 يوليو 2011
    المشاركات:
    7,573
    التخصص:
    Control & Instrumentation Engineering
    الجامعة:
    Kfupm
    سنة التخرج:
    2017
    التقييمات:
    +4,522 / 9 / -22
  12. Alucard

    Alucard عضو

    انضم:
    ‏4 يوليو 2012
    المشاركات:
    224
    التخصص:
    Petroleum Engineering
    الجامعة:
    KFUPM
    سنة التخرج:
    2017
    الوظيفة:
    Dota 2 Professional Player
    الإقامة:
    Dammam
    التقييمات:
    +84 / 1 / -11
    شباب لاب 9, files
    الي يعرف حل التاسكات ... u_u
     
  13. Alucard

    Alucard عضو

    انضم:
    ‏4 يوليو 2012
    المشاركات:
    224
    التخصص:
    Petroleum Engineering
    الجامعة:
    KFUPM
    سنة التخرج:
    2017
    الوظيفة:
    Dota 2 Professional Player
    الإقامة:
    Dammam
    التقييمات:
    +84 / 1 / -11
    كود:
    int
    main (void) {
    	FILE *in, *out;
    	char x;
    	int digit, lower, upper, other;
    	int status;
    	
    	in = fopen("data.txt", "r");
    		if (in == NULL) {
    			printf("Error: Failed to open Input File\n");
    			exit (1);
    		}
    		
    	out = fopen("summary.txt", "w");
    		
    	fscanf(in, "%c", &x);
    	while ( status != EOF) {
    		if ( x >= '0' && x <= '9') 
        	digit++;
        	else if ( x >= 'A' && x <= 'Z')
        	upper++;
        	 else if ( x >= 'a' && x <= 'z')
        	lower++;
        	else
        	other++; 
        	fscanf(in, "%c", &x);
        	status = fscanf(in, "%c", &x);
    	}
    		
     		fprintf(out, "Number of digits = %d\n", digit);
        	fprintf(out, "Number of lowercase letters = %d\n", lower);
        	fprintf(out, "Number of uppercase letters = %d\n", upper);
        	fprintf(out, "Number of other charectar = %d\n", other);
    	
    		fclose(in);
    		fclose(out);
    	return 0;
    }

    احد يعرف وين المشكله؟
     
  14. عبادي2013

    انضم:
    ‏1 يونيو 2014
    المشاركات:
    115
    التقييمات:
    +10 / 0 / -1
    شباب ايش المشكلة في دا الكود

    كود PHP:
    #include <stdio.h> 
    int main(void
    {
        
     
    FILE *in , *out ;
     
     
    in fopen("data.text" "r" ) ;
     
    out fopen("summray.text" "w");
     
     
    int status ;
     
    char ch ;
     
     
    int lc=uc=dc=oc=;
     
     if (
    in == NULL ) {
            
    printf("error : faild  to open data.text \n ") ;
            
    system ("PAUSE");
            exit(
    1) ;
            }
     while (
    status !=EOF ) {
     
            
    printf("%c" ch);
            
                if (
    ch>='0' && ch <= '9')
                
    dc++ ;
                else if (
    ch>='a' && ch<='z' )
                
    lc++ ;
                else if (
    ch>='A' && ch<='Z' )
                
    uc++ ;
                else 
                
    oc++ ;
            
    status=fscanf(in "%c" , &ch) ; 
        }
        
        
    fprintf(out "number of digits = %d \n"dc);
        
    fprintf(out "number of small letters = %d \n",lc );
        
    fprintf(out"number of big letters =%d \n",uc );
        
    fprintf(out "number of the other characters =%d\n" oc) ; 
        
        
        
    fclose (in);
        
    fclose (out);

        
        return 
    ;
                
    }
     


    ذا كود تاني لنفس السؤال والاثين ما يشتغلو معايا

    كود PHP:
    #include <stdio.h>
    int main ()
    {    
    FILE *in,*out;
            
    in=fopen("data.txt","r");
            
    out=fopen("summary.txt","w");
            
    int status;
             
    char ch;

          
    int dc=0,lc=0,uc=0,oc=0;

         while(
    1)
        {
               
    status=fscanf(in,"%c",&ch);
            if (
    status==EOF) break;
            {
            if (
    ch>='0' && ch<='9')
            
    dc++;
            else if (
    ch>='a' && ch<='z')
            
    lc++;
            else if (
    ch>='A' && ch<='Z')
            
    uc++;
            else
            
    oc++;
            }
         }
         
         
    fprintf(out,"number of digits=%d\n",dc);
         
    fprintf(out,"number of small letters=%d\n",lc);
         
    fprintf(out,"number of big letters=%d\n",uc);
         
    fprintf(out,"number of other characters=%d",oc);
         
         
            
    fclose(in);
            
    fclose(out);
            
    system("pause");
            return 
    0;
    }
     
  15. KinGraY

    KinGraY عضو

    انضم:
    ‏29 يونيو 2013
    المشاركات:
    73
    التقييمات:
    +14 / 0 / -2
    how can terminate a program if i the user enter a value i don't want
     
  16. بدر الغامدي

    انضم:
    ‏17 يوليو 2013
    المشاركات:
    359
    التخصص:
    CHE
    الجامعة:
    KFUPM
    سنة التخرج:
    181
    الجنس:
    ذكر
    التقييمات:
    +231 / 0 / -36
    #include<stdio.h>

    void scaning(double *l ,double *w) ;

    void computing(double *A , double *P) ;

    main(){
    double P , A , l , w ;

    scaning(&l ,&w);

    computing(A,P) ;

    printf(" A = %f P = %f", A , P ) ;

    return 0 ;

    }

    void scaning(double *l ,double *w) {
    printf("Enter the lenght ") ;
    scanf("%lf",l);
    printf("Enter the width ") ;
    scanf("%lf",w);
    }

    void computing(double *A , double *P, double l , double w) {

    *A = w * l ;
    *P = 2*(l+w) ;

    }

    وش الغلط يا شباب عجزت أطلعه
     
  17. بدر الغامدي

    انضم:
    ‏17 يوليو 2013
    المشاركات:
    359
    التخصص:
    CHE
    الجامعة:
    KFUPM
    سنة التخرج:
    181
    الجنس:
    ذكر
    التقييمات:
    +231 / 0 / -36
    كل شيء طلع بالمقلوب :")
     
  18. بدر الغامدي

    انضم:
    ‏17 يوليو 2013
    المشاركات:
    359
    التخصص:
    CHE
    الجامعة:
    KFUPM
    سنة التخرج:
    181
    الجنس:
    ذكر
    التقييمات:
    +231 / 0 / -36
    يعطيك العافية يا شباب حليت المشكلة
     
  19. Alucard

    Alucard عضو

    انضم:
    ‏4 يوليو 2012
    المشاركات:
    224
    التخصص:
    Petroleum Engineering
    الجامعة:
    KFUPM
    سنة التخرج:
    2017
    الوظيفة:
    Dota 2 Professional Player
    الإقامة:
    Dammam
    التقييمات:
    +84 / 1 / -11
    use return 1; or anything like exit (1); i hope it works
     
  20. عبادي2013

    انضم:
    ‏1 يونيو 2014
    المشاركات:
    115
    التقييمات:
    +10 / 0 / -1
    شباب عندي ذا الهوومورك
    ومني عارف كيف اسويه


    http://www.4shared.com/office/A0J7CP...103_T-141.html

    هذا رابط الملف

    وانا سويت كود بس ما عرفت اكمل وهذا هو الكود ياريت احد يقدر يساعدني
    كود PHP:
    #include<stdio.h>

    int main (void) {
        
        
    FILE *in , *out;
        
        
    in=fopen("Hw.text","r");
        
    out=fopen("data.text","w");
        
        
    char ch ;
        
    int status sl cl ;
        
        while (
    1)
        {
            
    printf("Enter the input file name: \n");
            
    status fscanf(in,"%c",&ch);
            if (
    status==EOF)  break ;{
                
            if (
    ch>='a' && ch>='z')
            
    sl++ ;
            else if (
    ch>='A' && ch>='Z')
            
    cl++ ; 
            
            }
        
            
            
            
        }
        


        
    fclose(in);
        
    fclose(out);
        
    system("pause");
        return 
    ;
        
        

    }  
     
جاري تحميل الصفحة...
مواضيع شبيهة - Ics 103 Computer Programming Discussion
  1. تقييم
    الردود:
    34
    المشاهدات:
    24,472
  2. Theking999
    الردود:
    3
    المشاهدات:
    1,686
  3. تقييم
    الردود:
    2
    المشاهدات:
    3,407
  4. newb
    الردود:
    32
    المشاهدات:
    8,008
  5. sajkab
    الردود:
    5
    المشاهدات:
    887
  6. Error_Handler
    الردود:
    1
    المشاهدات:
    4,494
  7. immortal vertcl
    الردود:
    0
    المشاهدات:
    492
  8. ~~~
    الردود:
    2
    المشاهدات:
    3,599
  9. Nevermind7
    الردود:
    0
    المشاهدات:
    329
  10. Nevermind7
    الردود:
    0
    المشاهدات:
    579

مشاركة هذه الصفحة